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();
849void TypePrinter::printConstantMatrixBefore(
const ConstantMatrixType *
T,
851 printBefore(
T->getElementType(), OS);
852 OS <<
" __attribute__((matrix_type(";
853 OS <<
T->getNumRows() <<
", " <<
T->getNumColumns();
857void TypePrinter::printConstantMatrixAfter(
const ConstantMatrixType *
T,
859 printAfter(
T->getElementType(), OS);
862void TypePrinter::printDependentSizedMatrixBefore(
863 const DependentSizedMatrixType *
T, raw_ostream &OS) {
864 printBefore(
T->getElementType(), OS);
865 OS <<
" __attribute__((matrix_type(";
866 if (
T->getRowExpr()) {
867 T->getRowExpr()->printPretty(OS,
nullptr, Policy);
870 if (
T->getColumnExpr()) {
871 T->getColumnExpr()->printPretty(OS,
nullptr, Policy);
876void TypePrinter::printDependentSizedMatrixAfter(
877 const DependentSizedMatrixType *
T, raw_ostream &OS) {
878 printAfter(
T->getElementType(), OS);
898 OS <<
" __attribute__((nothrow))";
914 if (
T->hasTrailingReturn()) {
916 if (!HasEmptyPlaceHolder)
921 printBefore(
T->getReturnType(), OS);
922 if (!PrevPHIsEmpty.get())
930 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
932 return "swift_context";
934 return "swift_async_context";
936 return "swift_error_result";
938 return "swift_indirect_result";
944 llvm_unreachable(
"bad parameter ABI kind");
950 if (!HasEmptyPlaceHolder)
956 ParamPolicyRAII ParamPolicy(Policy);
957 for (
unsigned i = 0, e =
T->getNumParams(); i != e; ++i) {
960 auto EPI =
T->getExtParameterInfo(i);
961 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
962 if (EPI.isNoEscape())
963 OS <<
"__attribute__((noescape)) ";
964 auto ABI = EPI.getABI();
972 print(
T->getParamType(i).getNonReferenceType(), OS, StringRef());
975 }
else if (ABI != ParameterABI::Ordinary)
997 OS <<
" __arm_streaming_compatible";
999 OS <<
" __arm_streaming";
1001 OS <<
"__arm_agnostic(\"sme_za_state\")";
1003 OS <<
" __arm_preserves(\"za\")";
1005 OS <<
" __arm_in(\"za\")";
1007 OS <<
" __arm_out(\"za\")";
1009 OS <<
" __arm_inout(\"za\")";
1011 OS <<
" __arm_preserves(\"zt0\")";
1013 OS <<
" __arm_in(\"zt0\")";
1015 OS <<
" __arm_out(\"zt0\")";
1017 OS <<
" __arm_inout(\"zt0\")";
1019 printFunctionAfter(Info, OS);
1039 for (
const auto &CFE : FX) {
1040 OS <<
" __attribute__((" << CFE.Effect.name();
1041 if (
const Expr *E = CFE.Cond.getCondition()) {
1043 E->printPretty(OS,
nullptr, Policy);
1050 OS <<
" __attribute__((cfi_unchecked_callee))";
1059void TypePrinter::printFunctionAfter(
const FunctionType::ExtInfo &Info,
1061 if (!InsideCCAttribute) {
1062 switch (Info.
getCC()) {
1073 OS <<
" __attribute__((stdcall))";
1076 OS <<
" __attribute__((fastcall))";
1079 OS <<
" __attribute__((thiscall))";
1082 OS <<
" __attribute__((vectorcall))";
1085 OS <<
" __attribute__((pascal))";
1088 OS <<
" __attribute__((pcs(\"aapcs\")))";
1091 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1094 OS <<
" __attribute__((aarch64_vector_pcs))";
1097 OS <<
" __attribute__((aarch64_sve_pcs))";
1100 OS <<
" __attribute__((device_kernel))";
1103 OS <<
" __attribute__((intel_ocl_bicc))";
1106 OS <<
" __attribute__((ms_abi))";
1109 OS <<
" __attribute__((sysv_abi))";
1112 OS <<
" __attribute__((regcall))";
1118 OS <<
" __attribute__((swiftcall))";
1121 OS <<
"__attribute__((swiftasynccall))";
1124 OS <<
" __attribute__((preserve_most))";
1127 OS <<
" __attribute__((preserve_all))";
1130 OS <<
" __attribute__((m68k_rtd))";
1133 OS <<
" __attribute__((preserve_none))";
1136 OS <<
"__attribute__((riscv_vector_cc))";
1138#define CC_VLS_CASE(ABI_VLEN) \
1139 case CC_RISCVVLSCall_##ABI_VLEN: \
1140 OS << "__attribute__((riscv_vls_cc" #ABI_VLEN "))"; \
1159 OS <<
" __attribute__((noreturn))";
1161 OS <<
" __attribute__((cmse_nonsecure_call))";
1163 OS <<
" __attribute__((ns_returns_retained))";
1165 OS <<
" __attribute__((regparm ("
1168 OS <<
" __attribute__((no_caller_saved_registers))";
1170 OS <<
" __attribute__((nocf_check))";
1173void TypePrinter::printFunctionNoProtoBefore(
const FunctionNoProtoType *
T,
1176 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder,
false);
1178 if (!PrevPHIsEmpty.get())
1182void TypePrinter::printFunctionNoProtoAfter(
const FunctionNoProtoType *
T,
1185 if (!HasEmptyPlaceHolder)
1187 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
1194void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) {
1204 spaceBeforePlaceHolder(OS);
1207void TypePrinter::printUnresolvedUsingBefore(
const UnresolvedUsingType *
T,
1209 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1210 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1212 auto *D =
T->getDecl();
1216 T->getQualifier().print(OS, Policy);
1219 spaceBeforePlaceHolder(OS);
1222void TypePrinter::printUnresolvedUsingAfter(
const UnresolvedUsingType *
T,
1225void TypePrinter::printUsingBefore(
const UsingType *
T, raw_ostream &OS) {
1226 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1227 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1229 auto *D =
T->getDecl();
1233 T->getQualifier().print(OS, Policy);
1236 spaceBeforePlaceHolder(OS);
1239void TypePrinter::printUsingAfter(
const UsingType *
T, raw_ostream &OS) {}
1241void TypePrinter::printTypedefBefore(
const TypedefType *
T, raw_ostream &OS) {
1242 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1243 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1245 auto *D =
T->getDecl();
1249 T->getQualifier().print(OS, Policy);
1252 spaceBeforePlaceHolder(OS);
1255void TypePrinter::printMacroQualifiedBefore(
const MacroQualifiedType *
T,
1257 StringRef MacroName =
T->getMacroIdentifier()->getName();
1258 OS << MacroName <<
" ";
1262 printBefore(
T->getModifiedType(), OS);
1265void TypePrinter::printMacroQualifiedAfter(
const MacroQualifiedType *
T,
1267 printAfter(
T->getModifiedType(), OS);
1270void TypePrinter::printTypedefAfter(
const TypedefType *
T, raw_ostream &OS) {}
1272void TypePrinter::printTypeOfExprBefore(
const TypeOfExprType *
T,
1274 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual "
1276 if (
T->getUnderlyingExpr())
1277 T->getUnderlyingExpr()->printPretty(OS,
nullptr, Policy);
1278 spaceBeforePlaceHolder(OS);
1281void TypePrinter::printTypeOfExprAfter(
const TypeOfExprType *
T,
1284void TypePrinter::printTypeOfBefore(
const TypeOfType *
T, raw_ostream &OS) {
1285 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual("
1287 print(
T->getUnmodifiedType(), OS, StringRef());
1289 spaceBeforePlaceHolder(OS);
1292void TypePrinter::printTypeOfAfter(
const TypeOfType *
T, raw_ostream &OS) {}
1294void TypePrinter::printDecltypeBefore(
const DecltypeType *
T, raw_ostream &OS) {
1296 if (
const Expr *E =
T->getUnderlyingExpr()) {
1297 PrintingPolicy ExprPolicy = Policy;
1299 E->printPretty(OS,
nullptr, ExprPolicy);
1302 spaceBeforePlaceHolder(OS);
1305void TypePrinter::printPackIndexingBefore(
const PackIndexingType *
T,
1307 if (
T->hasSelectedType()) {
1308 OS <<
T->getSelectedType();
1310 OS <<
T->getPattern() <<
"...[";
1311 T->getIndexExpr()->printPretty(OS,
nullptr, Policy);
1314 spaceBeforePlaceHolder(OS);
1317void TypePrinter::printPackIndexingAfter(
const PackIndexingType *
T,
1320void TypePrinter::printDecltypeAfter(
const DecltypeType *
T, raw_ostream &OS) {}
1322void TypePrinter::printUnaryTransformBefore(
const UnaryTransformType *
T,
1324 IncludeStrongLifetimeRAII Strong(Policy);
1326 static llvm::DenseMap<int, const char *> Transformation = {{
1327#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1328 {UnaryTransformType::Enum, "__" #Trait},
1329#include "clang/Basic/TransformTypeTraits.def"
1331 OS << Transformation[
T->getUTTKind()] <<
'(';
1332 print(
T->getBaseType(), OS, StringRef());
1334 spaceBeforePlaceHolder(OS);
1337void TypePrinter::printUnaryTransformAfter(
const UnaryTransformType *
T,
1340void TypePrinter::printAutoBefore(
const AutoType *
T, raw_ostream &OS) {
1342 if (!
T->getDeducedType().isNull()) {
1343 printBefore(
T->getDeducedType(), OS);
1345 if (
T->isConstrained()) {
1348 T->getTypeConstraintConcept()->getDeclName().print(OS, Policy);
1349 auto Args =
T->getTypeConstraintArguments();
1351 printTemplateArgumentList(
1353 T->getTypeConstraintConcept()->getTemplateParameters());
1356 switch (
T->getKeyword()) {
1357 case AutoTypeKeyword::Auto:
OS <<
"auto";
break;
1358 case AutoTypeKeyword::DecltypeAuto:
OS <<
"decltype(auto)";
break;
1359 case AutoTypeKeyword::GNUAutoType:
OS <<
"__auto_type";
break;
1361 spaceBeforePlaceHolder(OS);
1365void TypePrinter::printAutoAfter(
const AutoType *
T, raw_ostream &OS) {
1367 if (!
T->getDeducedType().isNull())
1368 printAfter(
T->getDeducedType(), OS);
1371void TypePrinter::printDeducedTemplateSpecializationBefore(
1372 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1374 T->getKeyword() != ElaboratedTypeKeyword::None)
1384 ArrayRef<TemplateArgument> Args;
1385 TemplateDecl *DeducedTD =
nullptr;
1386 if (!
T->getDeducedType().isNull()) {
1387 if (
const auto *TST =
1388 dyn_cast<TemplateSpecializationType>(
T->getDeducedType())) {
1389 DeducedTD = TST->getTemplateName().getAsTemplateDecl(
1391 Args = TST->template_arguments();
1396 DeducedTD = CD->getSpecializedTemplate();
1397 Args = CD->getTemplateArgs().asArray();
1411 IncludeStrongLifetimeRAII Strong(Policy);
1412 Name.
print(OS, Policy);
1415 printTemplateArgumentList(OS, Args, Policy,
1419 spaceBeforePlaceHolder(OS);
1422void TypePrinter::printDeducedTemplateSpecializationAfter(
1423 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1425 if (!
T->getDeducedType().isNull())
1426 printAfter(
T->getDeducedType(), OS);
1429void TypePrinter::printAtomicBefore(
const AtomicType *
T, raw_ostream &OS) {
1430 IncludeStrongLifetimeRAII Strong(Policy);
1433 print(
T->getValueType(), OS, StringRef());
1435 spaceBeforePlaceHolder(OS);
1438void TypePrinter::printAtomicAfter(
const AtomicType *
T, raw_ostream &OS) {}
1440void TypePrinter::printPipeBefore(
const PipeType *
T, raw_ostream &OS) {
1441 IncludeStrongLifetimeRAII Strong(Policy);
1443 if (
T->isReadOnly())
1446 OS <<
"write_only ";
1448 print(
T->getElementType(), OS, StringRef());
1449 spaceBeforePlaceHolder(OS);
1452void TypePrinter::printPipeAfter(
const PipeType *
T, raw_ostream &OS) {}
1454void TypePrinter::printBitIntBefore(
const BitIntType *
T, raw_ostream &OS) {
1455 if (
T->isUnsigned())
1457 OS <<
"_BitInt(" <<
T->getNumBits() <<
")";
1458 spaceBeforePlaceHolder(OS);
1461void TypePrinter::printBitIntAfter(
const BitIntType *
T, raw_ostream &OS) {}
1463void TypePrinter::printDependentBitIntBefore(
const DependentBitIntType *
T,
1465 if (
T->isUnsigned())
1468 T->getNumBitsExpr()->printPretty(OS,
nullptr, Policy);
1470 spaceBeforePlaceHolder(OS);
1473void TypePrinter::printDependentBitIntAfter(
const DependentBitIntType *
T,
1476void TypePrinter::printPredefinedSugarBefore(
const PredefinedSugarType *
T,
1478 OS <<
T->getIdentifier()->getName();
1479 spaceBeforePlaceHolder(OS);
1482void TypePrinter::printPredefinedSugarAfter(
const PredefinedSugarType *
T,
1486void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS,
1487 DeclarationName NameInScope) {
1499 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1501 return AppendScope(DC->
getParent(), OS, NameInScope);
1506 PrintingPolicy::SuppressInlineNamespaceMode::None &&
1507 NS->isInline() && NameInScope &&
1508 NS->isRedundantInlineQualifierFor(NameInScope))
1509 return AppendScope(DC->
getParent(), OS, NameInScope);
1511 AppendScope(DC->
getParent(), OS, NS->getDeclName());
1512 if (NS->getIdentifier())
1513 OS << NS->getName() <<
"::";
1515 OS <<
"(anonymous namespace)::";
1516 }
else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1517 AppendScope(DC->
getParent(), OS, Spec->getDeclName());
1518 IncludeStrongLifetimeRAII Strong(Policy);
1519 OS << Spec->getIdentifier()->getName();
1520 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
1521 printTemplateArgumentList(
1522 OS, TemplateArgs.
asArray(), Policy,
1523 Spec->getSpecializedTemplate()->getTemplateParameters());
1525 }
else if (
const auto *Tag = dyn_cast<TagDecl>(DC)) {
1527 if (TypedefNameDecl *
Typedef =
Tag->getTypedefNameForAnonDecl())
1528 OS <<
Typedef->getIdentifier()->getName() <<
"::";
1529 else if (
Tag->getIdentifier())
1530 OS <<
Tag->getIdentifier()->getName() <<
"::";
1534 AppendScope(DC->
getParent(), OS, NameInScope);
1538void TypePrinter::printTagType(
const TagType *
T, raw_ostream &OS) {
1539 TagDecl *D =
T->getOriginalDecl();
1542 D->
print(OS, Policy, Indentation);
1543 spaceBeforePlaceHolder(OS);
1547 bool HasKindDecoration =
false;
1551 HasKindDecoration =
true;
1556 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1557 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1562 T->getQualifier().print(OS, Policy);
1573 assert(
Typedef->getIdentifier() &&
"Typedef without identifier?");
1574 OS <<
Typedef->getIdentifier()->getName();
1582 HasKindDecoration =
true;
1593 if (!HasKindDecoration)
1601 llvm::SmallString<1024> WrittenFile(
File);
1603 WrittenFile = Callbacks->remapPath(
File);
1607 llvm::sys::path::Style Style =
1608 llvm::sys::path::is_absolute(WrittenFile)
1609 ? llvm::sys::path::Style::native
1611 ? llvm::sys::path::Style::windows_backslash
1612 : llvm::sys::path::Style::posix);
1613 llvm::sys::path::native(WrittenFile, Style);
1623 if (
auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1624 const TemplateParameterList *TParams =
1625 S->getSpecializedTemplate()->getTemplateParameters();
1626 const ASTTemplateArgumentListInfo *TArgAsWritten =
1627 S->getTemplateArgsAsWritten();
1628 IncludeStrongLifetimeRAII Strong(Policy);
1630 printTemplateArgumentList(OS, TArgAsWritten->
arguments(), Policy,
1633 printTemplateArgumentList(OS, S->getTemplateArgs().asArray(), Policy,
1637 spaceBeforePlaceHolder(OS);
1640void TypePrinter::printRecordBefore(
const RecordType *
T, raw_ostream &OS) {
1643 for (
const auto *PNA :
T->getOriginalDecl()
1644 ->getMostRecentDecl()
1645 ->specific_attrs<PreferredNameAttr>()) {
1647 T->getOriginalDecl()))
1650 QualType
T = PNA->getTypedefType();
1652 if (
auto *TT = dyn_cast<TypedefType>(
T))
1653 return printTypeSpec(TT->getDecl(), OS);
1654 if (
auto *TST = dyn_cast<TemplateSpecializationType>(
T))
1655 return printTemplateId(TST, OS,
true);
1661 printTagType(
T, OS);
1664void TypePrinter::printRecordAfter(
const RecordType *
T, raw_ostream &OS) {}
1666void TypePrinter::printEnumBefore(
const EnumType *
T, raw_ostream &OS) {
1667 printTagType(
T, OS);
1670void TypePrinter::printEnumAfter(
const EnumType *
T, raw_ostream &OS) {}
1672void TypePrinter::printInjectedClassNameBefore(
const InjectedClassNameType *
T,
1674 const ASTContext &Ctx =
T->getOriginalDecl()->getASTContext();
1675 IncludeStrongLifetimeRAII Strong(Policy);
1676 T->getTemplateName(Ctx).print(OS, Policy);
1678 auto *
Decl =
T->getOriginalDecl();
1681 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(Decl)) {
1682 printTemplateArgumentList(OS, RD->getTemplateArgsAsWritten()->arguments(),
1684 T->getTemplateDecl()->getTemplateParameters());
1686 ClassTemplateDecl *TD =
Decl->getDescribedClassTemplate();
1688 printTemplateArgumentList(
1690 T->getTemplateDecl()->getTemplateParameters());
1693 spaceBeforePlaceHolder(OS);
1696void TypePrinter::printInjectedClassNameAfter(
const InjectedClassNameType *
T,
1699void TypePrinter::printTemplateTypeParmBefore(
const TemplateTypeParmType *
T,
1701 TemplateTypeParmDecl *D =
T->getDecl();
1704 TC->print(OS, Policy);
1708 }
else if (IdentifierInfo *Id =
T->getIdentifier())
1712 OS <<
"type-parameter-" <<
T->getDepth() <<
'-' <<
T->getIndex();
1714 spaceBeforePlaceHolder(OS);
1717void TypePrinter::printTemplateTypeParmAfter(
const TemplateTypeParmType *
T,
1720void TypePrinter::printSubstTemplateTypeParmBefore(
1721 const SubstTemplateTypeParmType *
T,
1723 IncludeStrongLifetimeRAII Strong(Policy);
1724 printBefore(
T->getReplacementType(), OS);
1727void TypePrinter::printSubstTemplateTypeParmAfter(
1728 const SubstTemplateTypeParmType *
T,
1730 IncludeStrongLifetimeRAII Strong(Policy);
1731 printAfter(
T->getReplacementType(), OS);
1734void TypePrinter::printSubstBuiltinTemplatePackBefore(
1735 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {
1736 IncludeStrongLifetimeRAII Strong(Policy);
1740void TypePrinter::printSubstBuiltinTemplatePackAfter(
1741 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {}
1743void TypePrinter::printSubstTemplateTypeParmPackBefore(
1744 const SubstTemplateTypeParmPackType *
T,
1746 IncludeStrongLifetimeRAII Strong(Policy);
1747 if (
const TemplateTypeParmDecl *D =
T->getReplacedParameter()) {
1750 TC->print(OS, Policy);
1760 spaceBeforePlaceHolder(OS);
1764void TypePrinter::printSubstTemplateTypeParmPackAfter(
1765 const SubstTemplateTypeParmPackType *
T,
1767 IncludeStrongLifetimeRAII Strong(Policy);
1770void TypePrinter::printTemplateId(
const TemplateSpecializationType *
T,
1771 raw_ostream &OS,
bool FullyQualify) {
1772 IncludeStrongLifetimeRAII Strong(Policy);
1775 K != ElaboratedTypeKeyword::None)
1776 OS << TypeWithKeyword::getKeywordName(K) <<
' ';
1779 T->getTemplateName().getAsTemplateDecl(
true);
1781 if (FullyQualify && TD) {
1787 T->getTemplateName().print(OS, Policy,
1789 ? TemplateName::Qualified::AsWritten
1790 : TemplateName::Qualified::None);
1793 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1795 printTemplateArgumentList(OS,
T->template_arguments(), Policy, TPL);
1796 spaceBeforePlaceHolder(OS);
1799void TypePrinter::printTemplateSpecializationBefore(
1800 const TemplateSpecializationType *
T,
1805void TypePrinter::printTemplateSpecializationAfter(
1806 const TemplateSpecializationType *
T,
1809void TypePrinter::printParenBefore(
const ParenType *
T, raw_ostream &OS) {
1811 printBefore(
T->getInnerType(), OS);
1814 printBefore(
T->getInnerType(), OS);
1817void TypePrinter::printParenAfter(
const ParenType *
T, raw_ostream &OS) {
1820 printAfter(
T->getInnerType(), OS);
1822 printAfter(
T->getInnerType(), OS);
1825void TypePrinter::printDependentNameBefore(
const DependentNameType *
T,
1827 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1828 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1830 T->getQualifier().print(OS, Policy);
1831 OS <<
T->getIdentifier()->getName();
1832 spaceBeforePlaceHolder(OS);
1835void TypePrinter::printDependentNameAfter(
const DependentNameType *
T,
1838void TypePrinter::printPackExpansionBefore(
const PackExpansionType *
T,
1840 printBefore(
T->getPattern(), OS);
1843void TypePrinter::printPackExpansionAfter(
const PackExpansionType *
T,
1845 printAfter(
T->getPattern(), OS);
1853 if (
T->isCountInBytes() &&
T->isOrNull())
1854 OS <<
"__sized_by_or_null(";
1855 else if (
T->isCountInBytes())
1856 OS <<
"__sized_by(";
1857 else if (
T->isOrNull())
1858 OS <<
"__counted_by_or_null(";
1860 OS <<
"__counted_by(";
1861 if (
T->getCountExpr())
1862 T->getCountExpr()->printPretty(OS,
nullptr, Policy);
1866void TypePrinter::printCountAttributedBefore(
const CountAttributedType *
T,
1873void TypePrinter::printCountAttributedAfter(
const CountAttributedType *
T,
1880void TypePrinter::printAttributedBefore(
const AttributedType *
T,
1885 if (
T->getAttrKind() == attr::ObjCGC ||
1886 T->getAttrKind() == attr::ObjCOwnership)
1887 return printBefore(
T->getEquivalentType(), OS);
1889 if (
T->getAttrKind() == attr::ObjCKindOf)
1892 if (
T->getAttrKind() == attr::PreserveNone) {
1893 OS <<
"__attribute__((preserve_none)) ";
1894 spaceBeforePlaceHolder(OS);
1895 }
else if (
T->getAttrKind() == attr::PreserveMost) {
1896 OS <<
"__attribute__((preserve_most)) ";
1897 spaceBeforePlaceHolder(OS);
1898 }
else if (
T->getAttrKind() == attr::PreserveAll) {
1899 OS <<
"__attribute__((preserve_all)) ";
1900 spaceBeforePlaceHolder(OS);
1903 if (
T->getAttrKind() == attr::AddressSpace)
1904 printBefore(
T->getEquivalentType(), OS);
1906 printBefore(
T->getModifiedType(), OS);
1908 if (
T->isMSTypeSpec()) {
1909 switch (
T->getAttrKind()) {
1911 case attr::Ptr32:
OS <<
" __ptr32";
break;
1912 case attr::Ptr64:
OS <<
" __ptr64";
break;
1913 case attr::SPtr:
OS <<
" __sptr";
break;
1914 case attr::UPtr:
OS <<
" __uptr";
break;
1916 spaceBeforePlaceHolder(OS);
1919 if (
T->isWebAssemblyFuncrefSpec())
1923 if (
T->getImmediateNullability()) {
1924 if (
T->getAttrKind() == attr::TypeNonNull)
1926 else if (
T->getAttrKind() == attr::TypeNullable)
1928 else if (
T->getAttrKind() == attr::TypeNullUnspecified)
1929 OS <<
" _Null_unspecified";
1930 else if (
T->getAttrKind() == attr::TypeNullableResult)
1931 OS <<
" _Nullable_result";
1933 llvm_unreachable(
"unhandled nullability");
1934 spaceBeforePlaceHolder(OS);
1938void TypePrinter::printAttributedAfter(
const AttributedType *
T,
1943 if (
T->getAttrKind() == attr::ObjCGC ||
1944 T->getAttrKind() == attr::ObjCOwnership)
1945 return printAfter(
T->getEquivalentType(), OS);
1949 SaveAndRestore MaybeSuppressCC(InsideCCAttribute,
T->isCallingConv());
1951 printAfter(
T->getModifiedType(), OS);
1955 if (
T->getAttrKind() == attr::ObjCKindOf ||
T->isMSTypeSpec() ||
1956 T->getImmediateNullability() ||
T->isWebAssemblyFuncrefSpec())
1960 if (
T->getAttrKind() == attr::ObjCInertUnsafeUnretained)
1964 if (
T->getAttrKind() == attr::NSReturnsRetained &&
1965 !
T->getEquivalentType()->
castAs<FunctionType>()
1966 ->getExtInfo().getProducesResult())
1969 if (
T->getAttrKind() == attr::LifetimeBound) {
1970 OS <<
" [[clang::lifetimebound]]";
1973 if (
T->getAttrKind() == attr::LifetimeCaptureBy) {
1974 OS <<
" [[clang::lifetime_capture_by(";
1975 if (
auto *attr = dyn_cast_or_null<LifetimeCaptureByAttr>(
T->getAttr()))
1976 llvm::interleaveComma(
attr->getArgIdents(), OS,
1977 [&](
auto it) { OS << it->getName(); });
1985 if (
T->getAttrKind() == attr::AddressSpace)
1988 if (
T->getAttrKind() == attr::AnnotateType) {
1993 OS <<
" [[clang::annotate_type(...)]]";
1997 if (
T->getAttrKind() == attr::ArmStreaming) {
1998 OS <<
"__arm_streaming";
2001 if (
T->getAttrKind() == attr::ArmStreamingCompatible) {
2002 OS <<
"__arm_streaming_compatible";
2006 if (
T->getAttrKind() == attr::SwiftAttr) {
2007 if (
auto *swiftAttr = dyn_cast_or_null<SwiftAttrAttr>(
T->getAttr())) {
2008 OS <<
" __attribute__((swift_attr(\"" << swiftAttr->getAttribute()
2014 if (
T->getAttrKind() == attr::PreserveAll ||
2015 T->getAttrKind() == attr::PreserveMost ||
2016 T->getAttrKind() == attr::PreserveNone) {
2021 OS <<
" __attribute__((";
2022 switch (
T->getAttrKind()) {
2023#define TYPE_ATTR(NAME)
2024#define DECL_OR_TYPE_ATTR(NAME)
2025#define ATTR(NAME) case attr::NAME:
2026#include "clang/Basic/AttrList.inc"
2027 llvm_unreachable(
"non-type attribute attached to type");
2029 case attr::BTFTypeTag:
2030 llvm_unreachable(
"BTFTypeTag attribute handled separately");
2032 case attr::HLSLResourceClass:
2034 case attr::HLSLRawBuffer:
2035 case attr::HLSLContainedType:
2036 llvm_unreachable(
"HLSL resource type attributes handled separately");
2038 case attr::OpenCLPrivateAddressSpace:
2039 case attr::OpenCLGlobalAddressSpace:
2040 case attr::OpenCLGlobalDeviceAddressSpace:
2041 case attr::OpenCLGlobalHostAddressSpace:
2042 case attr::OpenCLLocalAddressSpace:
2043 case attr::OpenCLConstantAddressSpace:
2044 case attr::OpenCLGenericAddressSpace:
2045 case attr::HLSLGroupSharedAddressSpace:
2050 case attr::CountedBy:
2051 case attr::CountedByOrNull:
2053 case attr::SizedByOrNull:
2054 case attr::LifetimeBound:
2055 case attr::LifetimeCaptureBy:
2056 case attr::TypeNonNull:
2057 case attr::TypeNullable:
2058 case attr::TypeNullableResult:
2059 case attr::TypeNullUnspecified:
2061 case attr::ObjCInertUnsafeUnretained:
2062 case attr::ObjCKindOf:
2063 case attr::ObjCOwnership:
2068 case attr::PointerAuth:
2069 case attr::AddressSpace:
2070 case attr::CmseNSCall:
2071 case attr::AnnotateType:
2072 case attr::WebAssemblyFuncref:
2073 case attr::ArmAgnostic:
2074 case attr::ArmStreaming:
2075 case attr::ArmStreamingCompatible:
2078 case attr::ArmInOut:
2079 case attr::ArmPreserves:
2080 case attr::NonBlocking:
2081 case attr::NonAllocating:
2082 case attr::Blocking:
2083 case attr::Allocating:
2084 case attr::SwiftAttr:
2085 case attr::PreserveAll:
2086 case attr::PreserveMost:
2087 case attr::PreserveNone:
2088 llvm_unreachable(
"This attribute should have been handled already");
2090 case attr::NSReturnsRetained:
2091 OS <<
"ns_returns_retained";
2096 case attr::AnyX86NoCfCheck:
OS <<
"nocf_check";
break;
2097 case attr::CDecl:
OS <<
"cdecl";
break;
2098 case attr::FastCall:
OS <<
"fastcall";
break;
2099 case attr::StdCall:
OS <<
"stdcall";
break;
2100 case attr::ThisCall:
OS <<
"thiscall";
break;
2101 case attr::SwiftCall:
OS <<
"swiftcall";
break;
2102 case attr::SwiftAsyncCall:
OS <<
"swiftasynccall";
break;
2103 case attr::VectorCall:
OS <<
"vectorcall";
break;
2104 case attr::Pascal:
OS <<
"pascal";
break;
2105 case attr::MSABI:
OS <<
"ms_abi";
break;
2106 case attr::SysVABI:
OS <<
"sysv_abi";
break;
2107 case attr::RegCall:
OS <<
"regcall";
break;
2110 QualType t =
T->getEquivalentType();
2114 "\"aapcs\"" :
"\"aapcs-vfp\"");
2118 case attr::AArch64VectorPcs:
OS <<
"aarch64_vector_pcs";
break;
2119 case attr::AArch64SVEPcs:
OS <<
"aarch64_sve_pcs";
break;
2120 case attr::DeviceKernel:
2121 OS <<
T->getAttr()->getSpelling();
2123 case attr::IntelOclBicc:
2124 OS <<
"inteloclbicc";
2129 case attr::RISCVVectorCC:
2130 OS <<
"riscv_vector_cc";
2132 case attr::RISCVVLSCC:
2133 OS <<
"riscv_vls_cc";
2138 case attr::CFIUncheckedCallee:
2139 OS <<
"cfi_unchecked_callee";
2141 case attr::AcquireHandle:
2142 OS <<
"acquire_handle";
2144 case attr::ArmMveStrictPolymorphism:
2145 OS <<
"__clang_arm_mve_strict_polymorphism";
2147 case attr::ExtVectorType:
2148 OS <<
"ext_vector_type";
2157void TypePrinter::printBTFTagAttributedBefore(
const BTFTagAttributedType *
T,
2159 printBefore(
T->getWrappedType(), OS);
2160 OS <<
" __attribute__((btf_type_tag(\"" <<
T->getAttr()->getBTFTypeTag() <<
"\")))";
2163void TypePrinter::printBTFTagAttributedAfter(
const BTFTagAttributedType *
T,
2165 printAfter(
T->getWrappedType(), OS);
2168void TypePrinter::printHLSLAttributedResourceBefore(
2169 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2170 printBefore(
T->getWrappedType(), OS);
2173void TypePrinter::printHLSLAttributedResourceAfter(
2174 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2175 printAfter(
T->getWrappedType(), OS);
2176 const HLSLAttributedResourceType::Attributes &Attrs =
T->getAttrs();
2177 OS <<
" [[hlsl::resource_class("
2178 << HLSLResourceClassAttr::ConvertResourceClassToStr(Attrs.ResourceClass)
2181 OS <<
" [[hlsl::is_rov]]";
2182 if (Attrs.RawBuffer)
2183 OS <<
" [[hlsl::raw_buffer]]";
2185 QualType ContainedTy =
T->getContainedType();
2186 if (!ContainedTy.
isNull()) {
2187 OS <<
" [[hlsl::contained_type(";
2188 printBefore(ContainedTy, OS);
2189 printAfter(ContainedTy, OS);
2194void TypePrinter::printHLSLInlineSpirvBefore(
const HLSLInlineSpirvType *
T,
2196 OS <<
"__hlsl_spirv_type<" <<
T->getOpcode();
2198 OS <<
", " <<
T->getSize();
2199 OS <<
", " <<
T->getAlignment();
2201 for (
auto &Operand :
T->getOperands()) {
2202 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2206 case SpirvOperandKind::ConstantId: {
2207 QualType ConstantType =
Operand.getResultType();
2208 OS <<
"vk::integral_constant<";
2209 printBefore(ConstantType, OS);
2210 printAfter(ConstantType, OS);
2216 case SpirvOperandKind::Literal:
2217 OS <<
"vk::Literal<vk::integral_constant<uint, ";
2221 case SpirvOperandKind::TypeId: {
2223 printBefore(
Type, OS);
2224 printAfter(
Type, OS);
2228 llvm_unreachable(
"Invalid SpirvOperand kind!");
2236void TypePrinter::printHLSLInlineSpirvAfter(
const HLSLInlineSpirvType *
T,
2241void TypePrinter::printObjCInterfaceBefore(
const ObjCInterfaceType *
T,
2243 OS <<
T->getDecl()->getName();
2244 spaceBeforePlaceHolder(OS);
2247void TypePrinter::printObjCInterfaceAfter(
const ObjCInterfaceType *
T,
2250void TypePrinter::printObjCTypeParamBefore(
const ObjCTypeParamType *
T,
2252 OS <<
T->getDecl()->getName();
2253 if (!
T->qual_empty()) {
2254 bool isFirst =
true;
2256 for (
const auto *I :
T->quals()) {
2266 spaceBeforePlaceHolder(OS);
2269void TypePrinter::printObjCTypeParamAfter(
const ObjCTypeParamType *
T,
2272void TypePrinter::printObjCObjectBefore(
const ObjCObjectType *
T,
2274 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2275 !
T->isKindOfTypeAsWritten())
2276 return printBefore(
T->getBaseType(), OS);
2278 if (
T->isKindOfTypeAsWritten())
2281 print(
T->getBaseType(), OS, StringRef());
2283 if (
T->isSpecializedAsWritten()) {
2284 bool isFirst =
true;
2286 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
2292 print(typeArg, OS, StringRef());
2297 if (!
T->qual_empty()) {
2298 bool isFirst =
true;
2300 for (
const auto *I :
T->quals()) {
2310 spaceBeforePlaceHolder(OS);
2313void TypePrinter::printObjCObjectAfter(
const ObjCObjectType *
T,
2315 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2316 !
T->isKindOfTypeAsWritten())
2317 return printAfter(
T->getBaseType(), OS);
2320void TypePrinter::printObjCObjectPointerBefore(
const ObjCObjectPointerType *
T,
2327 if (HasEmptyPlaceHolder)
2333void TypePrinter::printObjCObjectPointerAfter(
const ObjCObjectPointerType *
T,
2344 llvm::raw_ostream &OS,
bool IncludeType) {
2345 A.
print(PP, OS, IncludeType);
2358 TemplateArgument Pattern,
2359 ArrayRef<TemplateArgument> Args,
2368 if (
auto *TTPT = Pattern->
getAsCanonical<TemplateTypeParmType>()) {
2369 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2372 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2384 if (TQual != PatQual)
2389 QualType TPointee =
T->getPointeeType();
2401 if (
auto *TTST =
T->getAs<TemplateSpecializationType>()) {
2402 Template = TTST->getTemplateName();
2403 TemplateArgs = TTST->template_arguments();
2404 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2405 T->getAsCXXRecordDecl())) {
2407 TemplateArgs = CTSD->getTemplateArgs().asArray();
2415 if (TemplateArgs.size() != PTST->template_arguments().size())
2417 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2419 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2470 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2471 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2472 Args[NTTP->getIndex()].structurallyEquals(Arg);
2488 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2489 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2498bool clang::isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
2499 const NamedDecl *Param,
2500 ArrayRef<TemplateArgument> Args,
2506 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2507 return TTPD->hasDefaultArgument() &&
2509 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2510 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2511 return TTPD->hasDefaultArgument() &&
2513 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2514 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2515 return NTTPD->hasDefaultArgument() &&
2517 Ctx, Arg, NTTPD->getDefaultArgument().getArgument(), Args,
2523template <
typename TA>
2529 !Args.empty() && !IsPack && Args.size() <= TPL->
size()) {
2531 for (
const TA &A : Args)
2533 while (!Args.empty() &&
getArgument(Args.back()).getIsDefaulted())
2534 Args = Args.drop_back();
2541 bool NeedSpace =
false;
2542 bool FirstArg =
true;
2543 for (
const auto &Arg : Args) {
2546 llvm::raw_svector_ostream ArgOS(Buf);
2559 Policy, TPL, ParmIndex));
2561 StringRef ArgString = ArgOS.str();
2566 if (FirstArg && ArgString.starts_with(
":"))
2573 if (!ArgString.empty()) {
2590void clang::printTemplateArgumentList(raw_ostream &OS,
2591 const TemplateArgumentListInfo &Args,
2592 const PrintingPolicy &Policy,
2593 const TemplateParameterList *TPL) {
2594 printTemplateArgumentList(OS, Args.
arguments(), Policy, TPL);
2597void clang::printTemplateArgumentList(raw_ostream &OS,
2598 ArrayRef<TemplateArgument> Args,
2599 const PrintingPolicy &Policy,
2600 const TemplateParameterList *TPL) {
2601 PrintingPolicy InnerPolicy = Policy;
2603 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2606void clang::printTemplateArgumentList(raw_ostream &OS,
2607 ArrayRef<TemplateArgumentLoc> Args,
2608 const PrintingPolicy &Policy,
2609 const TemplateParameterList *TPL) {
2610 PrintingPolicy InnerPolicy = Policy;
2612 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2622 llvm::raw_svector_ostream StrOS(Buf);
2624 return StrOS.str().str();
2652 llvm::raw_svector_ostream StrOS(Buf);
2653 print(StrOS, Policy);
2654 return std::string(StrOS.str());
2672 PointerAuth && !PointerAuth.isEmptyWhenPrinted(Policy))
2692 return "__constant";
2697 return "__global_device";
2700 return "__global_host";
2702 return "__device__";
2704 return "__constant__";
2706 return "__shared__";
2708 return "__sptr __ptr32";
2710 return "__uptr __ptr32";
2714 return "groupshared";
2716 return "hlsl_constant";
2718 return "hlsl_private";
2720 return "hlsl_device";
2722 return "hlsl_input";
2734 bool appendSpaceIfNonEmpty)
const {
2735 bool addSpace =
false;
2745 OS <<
"__unaligned";
2749 if (!ASStr.empty()) {
2755 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2794 PointerAuth.print(OS, Policy);
2797 if (appendSpaceIfNonEmpty && addSpace)
2819 const Twine &PlaceHolder,
unsigned Indentation)
const {
2826 const Twine &PlaceHolder,
unsigned Indentation) {
2828 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2830 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2840 std::string &buffer,
2843 llvm::raw_svector_ostream StrOS(Buf);
2844 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2845 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 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 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 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, 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...
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.