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 printTagType(
const TagType *
T, raw_ostream &OS);
135 void printFunctionAfter(
const FunctionType::ExtInfo &Info, raw_ostream &OS);
136#define ABSTRACT_TYPE(CLASS, PARENT)
137#define TYPE(CLASS, PARENT) \
138 void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
139 void print##CLASS##After(const CLASS##Type *T, raw_ostream &OS);
140#include "clang/AST/TypeNodes.inc"
150 bool HasRestrictKeyword) {
151 bool appendSpace =
false;
157 if (appendSpace) OS <<
' ';
162 if (appendSpace) OS <<
' ';
163 if (HasRestrictKeyword) {
171void TypePrinter::spaceBeforePlaceHolder(raw_ostream &OS) {
172 if (!HasEmptyPlaceHolder)
178 if (Policy.PrintAsCanonical)
183void TypePrinter::print(QualType t, raw_ostream &OS, StringRef PlaceHolder) {
188void TypePrinter::print(
const Type *
T, Qualifiers Quals, raw_ostream &OS,
189 StringRef PlaceHolder) {
195 SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
197 printBefore(
T, Quals, OS);
199 printAfter(
T, Quals, OS);
202bool TypePrinter::canPrefixQualifiers(
const Type *
T,
203 bool &NeedARCStrongQualifier) {
209 bool CanPrefixQualifiers =
false;
210 NeedARCStrongQualifier =
false;
211 const Type *UnderlyingType =
T;
212 if (
const auto *AT = dyn_cast<AutoType>(
T))
213 UnderlyingType = AT->desugar().getTypePtr();
214 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
T))
215 UnderlyingType = Subst->getReplacementType().getTypePtr();
222 case Type::UnresolvedUsing:
225 case Type::TypeOfExpr:
228 case Type::UnaryTransform:
231 case Type::TemplateTypeParm:
232 case Type::SubstTemplateTypeParmPack:
233 case Type::SubstBuiltinTemplatePack:
234 case Type::DeducedTemplateSpecialization:
235 case Type::TemplateSpecialization:
236 case Type::InjectedClassName:
237 case Type::DependentName:
238 case Type::ObjCObject:
239 case Type::ObjCTypeParam:
240 case Type::ObjCInterface:
244 case Type::DependentBitInt:
245 case Type::OverflowBehavior:
246 case Type::BTFTagAttributed:
247 case Type::HLSLAttributedResource:
248 case Type::HLSLInlineSpirv:
249 case Type::PredefinedSugar:
250 CanPrefixQualifiers =
true;
253 case Type::ObjCObjectPointer:
258 case Type::VariableArray:
259 case Type::DependentSizedArray:
260 NeedARCStrongQualifier =
true;
263 case Type::ConstantArray:
264 case Type::IncompleteArray:
265 return canPrefixQualifiers(
267 NeedARCStrongQualifier);
271 case Type::ArrayParameter:
273 case Type::BlockPointer:
274 case Type::LValueReference:
275 case Type::RValueReference:
276 case Type::MemberPointer:
277 case Type::DependentAddressSpace:
278 case Type::DependentVector:
279 case Type::DependentSizedExtVector:
281 case Type::ExtVector:
282 case Type::ConstantMatrix:
283 case Type::DependentSizedMatrix:
284 case Type::FunctionProto:
285 case Type::FunctionNoProto:
287 case Type::PackExpansion:
288 case Type::SubstTemplateTypeParm:
289 case Type::MacroQualified:
290 case Type::CountAttributed:
291 case Type::LateParsedAttr:
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, raw_ostream &OS) {
645 print(
T->getElementType(), OS, StringRef());
647 if (
T->getSizeExpr())
648 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
650 spaceBeforePlaceHolder(OS);
652 printBefore(
T->getElementType(), OS);
656void TypePrinter::printDependentSizedExtVectorAfter(
657 const DependentSizedExtVectorType *
T, raw_ostream &OS) {
661 OS <<
" __attribute__((ext_vector_type(";
662 if (
T->getSizeExpr())
663 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
665 printAfter(
T->getElementType(), OS);
668void TypePrinter::printVectorBefore(
const VectorType *
T, raw_ostream &OS) {
669 switch (
T->getVectorKind()) {
670 case VectorKind::AltiVecPixel:
671 OS <<
"__vector __pixel ";
673 case VectorKind::AltiVecBool:
674 OS <<
"__vector __bool ";
675 printBefore(
T->getElementType(), OS);
677 case VectorKind::AltiVecVector:
679 printBefore(
T->getElementType(), OS);
681 case VectorKind::Neon:
682 OS <<
"__attribute__((neon_vector_type("
683 <<
T->getNumElements() <<
"))) ";
684 printBefore(
T->getElementType(), OS);
686 case VectorKind::NeonPoly:
687 OS <<
"__attribute__((neon_polyvector_type(" <<
688 T->getNumElements() <<
"))) ";
689 printBefore(
T->getElementType(), OS);
691 case VectorKind::Generic: {
694 OS <<
"__attribute__((__vector_size__("
695 <<
T->getNumElements()
697 print(
T->getElementType(), OS, StringRef());
699 printBefore(
T->getElementType(), OS);
702 case VectorKind::SveFixedLengthData:
703 case VectorKind::SveFixedLengthPredicate:
706 OS <<
"__attribute__((__arm_sve_vector_bits__(";
708 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
711 OS <<
T->getNumElements() * 8;
713 OS <<
T->getNumElements();
716 print(
T->getElementType(), OS, StringRef());
719 printBefore(
T->getElementType(), OS);
721 case VectorKind::RVVFixedLengthData:
722 case VectorKind::RVVFixedLengthMask:
723 case VectorKind::RVVFixedLengthMask_1:
724 case VectorKind::RVVFixedLengthMask_2:
725 case VectorKind::RVVFixedLengthMask_4:
728 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
729 switch (
T->getVectorKind()) {
730 case VectorKind::RVVFixedLengthMask_1:
733 case VectorKind::RVVFixedLengthMask_2:
736 case VectorKind::RVVFixedLengthMask_4:
740 OS <<
T->getNumElements();
742 print(
T->getElementType(), OS, StringRef());
748 printBefore(
T->getElementType(), OS);
753void TypePrinter::printVectorAfter(
const VectorType *
T, raw_ostream &OS) {
754 printAfter(
T->getElementType(), OS);
757void TypePrinter::printDependentVectorBefore(
758 const DependentVectorType *
T, raw_ostream &OS) {
759 switch (
T->getVectorKind()) {
760 case VectorKind::AltiVecPixel:
761 OS <<
"__vector __pixel ";
763 case VectorKind::AltiVecBool:
764 OS <<
"__vector __bool ";
765 printBefore(
T->getElementType(), OS);
767 case VectorKind::AltiVecVector:
769 printBefore(
T->getElementType(), OS);
771 case VectorKind::Neon:
772 OS <<
"__attribute__((neon_vector_type(";
773 if (
T->getSizeExpr())
774 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
776 printBefore(
T->getElementType(), OS);
778 case VectorKind::NeonPoly:
779 OS <<
"__attribute__((neon_polyvector_type(";
780 if (
T->getSizeExpr())
781 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
783 printBefore(
T->getElementType(), OS);
785 case VectorKind::Generic: {
788 OS <<
"__attribute__((__vector_size__(";
789 if (
T->getSizeExpr())
790 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
792 print(
T->getElementType(), OS, StringRef());
794 printBefore(
T->getElementType(), OS);
797 case VectorKind::SveFixedLengthData:
798 case VectorKind::SveFixedLengthPredicate:
801 OS <<
"__attribute__((__arm_sve_vector_bits__(";
802 if (
T->getSizeExpr()) {
803 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
804 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
809 print(
T->getElementType(), OS, StringRef());
814 printBefore(
T->getElementType(), OS);
816 case VectorKind::RVVFixedLengthData:
817 case VectorKind::RVVFixedLengthMask:
818 case VectorKind::RVVFixedLengthMask_1:
819 case VectorKind::RVVFixedLengthMask_2:
820 case VectorKind::RVVFixedLengthMask_4:
823 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
824 switch (
T->getVectorKind()) {
825 case VectorKind::RVVFixedLengthMask_1:
828 case VectorKind::RVVFixedLengthMask_2:
831 case VectorKind::RVVFixedLengthMask_4:
835 if (
T->getSizeExpr()) {
836 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
838 print(
T->getElementType(), OS, StringRef());
845 printBefore(
T->getElementType(), OS);
850void TypePrinter::printDependentVectorAfter(
851 const DependentVectorType *
T, raw_ostream &OS) {
852 printAfter(
T->getElementType(), OS);
855void TypePrinter::printExtVectorBefore(
const ExtVectorType *
T,
859 print(
T->getElementType(), OS, StringRef());
860 OS <<
", " <<
T->getNumElements() <<
">";
861 spaceBeforePlaceHolder(OS);
863 printBefore(
T->getElementType(), OS);
867void TypePrinter::printExtVectorAfter(
const ExtVectorType *
T, raw_ostream &OS) {
871 printAfter(
T->getElementType(), OS);
872 OS <<
" __attribute__((ext_vector_type(";
873 OS <<
T->getNumElements();
878 OS <<
T->getNumRows() <<
", " <<
T->getNumColumns();
884 TP.print(
T->getElementType(), OS, StringRef());
888 TP.spaceBeforePlaceHolder(OS);
896 TP.printBefore(
T->getElementType(), OS);
897 OS <<
" __attribute__((matrix_type(";
902void TypePrinter::printConstantMatrixBefore(
const ConstantMatrixType *
T,
911void TypePrinter::printConstantMatrixAfter(
const ConstantMatrixType *
T,
917 printAfter(
T->getElementType(), OS);
920void TypePrinter::printDependentSizedMatrixBefore(
921 const DependentSizedMatrixType *
T, raw_ostream &OS) {
924 print(
T->getElementType(), OS, StringRef());
927 T->getRowExpr()->printPretty(OS,
nullptr, Policy);
929 if (
T->getColumnExpr())
930 T->getColumnExpr()->printPretty(OS,
nullptr, Policy);
932 spaceBeforePlaceHolder(OS);
934 printBefore(
T->getElementType(), OS);
935 OS <<
" __attribute__((matrix_type(";
937 T->getRowExpr()->printPretty(OS,
nullptr, Policy);
939 if (
T->getColumnExpr())
940 T->getColumnExpr()->printPretty(OS,
nullptr, Policy);
945void TypePrinter::printDependentSizedMatrixAfter(
946 const DependentSizedMatrixType *
T, raw_ostream &OS) {
948 printAfter(
T->getElementType(), OS);
968 OS <<
" __attribute__((nothrow))";
984 if (
T->hasTrailingReturn()) {
986 if (!HasEmptyPlaceHolder)
991 printBefore(
T->getReturnType(), OS);
992 if (!PrevPHIsEmpty.get())
1000 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
1002 return "swift_context";
1004 return "swift_async_context";
1006 return "swift_error_result";
1008 return "swift_indirect_result";
1014 llvm_unreachable(
"bad parameter ABI kind");
1020 if (!HasEmptyPlaceHolder)
1026 ParamPolicyRAII ParamPolicy(Policy);
1027 for (
unsigned i = 0, e =
T->getNumParams(); i != e; ++i) {
1030 auto EPI =
T->getExtParameterInfo(i);
1031 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
1032 if (EPI.isNoEscape())
1033 OS <<
"__attribute__((noescape)) ";
1034 auto ABI = EPI.getABI();
1042 print(
T->getParamType(i).getNonReferenceType(), OS, StringRef());
1045 }
else if (ABI != ParameterABI::Ordinary)
1067 OS <<
" __arm_streaming_compatible";
1069 OS <<
" __arm_streaming";
1071 OS <<
"__arm_agnostic(\"sme_za_state\")";
1073 OS <<
" __arm_preserves(\"za\")";
1075 OS <<
" __arm_in(\"za\")";
1077 OS <<
" __arm_out(\"za\")";
1079 OS <<
" __arm_inout(\"za\")";
1081 OS <<
" __arm_preserves(\"zt0\")";
1083 OS <<
" __arm_in(\"zt0\")";
1085 OS <<
" __arm_out(\"zt0\")";
1087 OS <<
" __arm_inout(\"zt0\")";
1089 printFunctionAfter(Info, OS);
1109 for (
const auto &CFE : FX) {
1110 OS <<
" __attribute__((" << CFE.Effect.name();
1111 if (
const Expr *E = CFE.Cond.getCondition()) {
1113 E->printPretty(OS,
nullptr, Policy);
1120 OS <<
" __attribute__((cfi_unchecked_callee))";
1129void TypePrinter::printFunctionAfter(
const FunctionType::ExtInfo &Info,
1131 if (!InsideCCAttribute) {
1132 switch (Info.
getCC()) {
1143 OS <<
" __attribute__((stdcall))";
1146 OS <<
" __attribute__((fastcall))";
1149 OS <<
" __attribute__((thiscall))";
1152 OS <<
" __attribute__((vectorcall))";
1155 OS <<
" __attribute__((pascal))";
1158 OS <<
" __attribute__((pcs(\"aapcs\")))";
1161 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1164 OS <<
" __attribute__((aarch64_vector_pcs))";
1167 OS <<
" __attribute__((aarch64_sve_pcs))";
1170 OS <<
" __attribute__((device_kernel))";
1173 OS <<
" __attribute__((intel_ocl_bicc))";
1176 OS <<
" __attribute__((ms_abi))";
1179 OS <<
" __attribute__((sysv_abi))";
1182 OS <<
" __attribute__((regcall))";
1185 OS <<
" __attribute__((swiftcall))";
1188 OS <<
"__attribute__((swiftasynccall))";
1191 OS <<
" __attribute__((preserve_most))";
1194 OS <<
" __attribute__((preserve_all))";
1197 OS <<
" __attribute__((m68k_rtd))";
1200 OS <<
" __attribute__((preserve_none))";
1203 OS <<
"__attribute__((riscv_vector_cc))";
1205#define CC_VLS_CASE(ABI_VLEN) \
1206 case CC_RISCVVLSCall_##ABI_VLEN: \
1207 OS << "__attribute__((riscv_vls_cc" #ABI_VLEN "))"; \
1226 OS <<
" __attribute__((noreturn))";
1228 OS <<
" __attribute__((cmse_nonsecure_call))";
1230 OS <<
" __attribute__((ns_returns_retained))";
1232 OS <<
" __attribute__((regparm ("
1235 OS <<
" __attribute__((no_caller_saved_registers))";
1237 OS <<
" __attribute__((nocf_check))";
1240void TypePrinter::printFunctionNoProtoBefore(
const FunctionNoProtoType *
T,
1243 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder,
false);
1245 if (!PrevPHIsEmpty.get())
1249void TypePrinter::printFunctionNoProtoAfter(
const FunctionNoProtoType *
T,
1252 if (!HasEmptyPlaceHolder)
1254 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
1261void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) {
1271 spaceBeforePlaceHolder(OS);
1274void TypePrinter::printUnresolvedUsingBefore(
const UnresolvedUsingType *
T,
1276 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1277 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1279 auto *D =
T->getDecl();
1283 T->getQualifier().print(OS, Policy);
1286 spaceBeforePlaceHolder(OS);
1289void TypePrinter::printUnresolvedUsingAfter(
const UnresolvedUsingType *
T,
1292void TypePrinter::printUsingBefore(
const UsingType *
T, raw_ostream &OS) {
1293 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1294 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1296 auto *D =
T->getDecl();
1297 if (Policy.FullyQualifiedName) {
1300 T->getQualifier().print(OS, Policy);
1303 spaceBeforePlaceHolder(OS);
1306void TypePrinter::printUsingAfter(
const UsingType *
T, raw_ostream &OS) {}
1308void TypePrinter::printTypedefBefore(
const TypedefType *
T, raw_ostream &OS) {
1309 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1310 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1312 auto *D =
T->getDecl();
1313 if (Policy.FullyQualifiedName) {
1316 T->getQualifier().print(OS, Policy);
1319 spaceBeforePlaceHolder(OS);
1322void TypePrinter::printMacroQualifiedBefore(
const MacroQualifiedType *
T,
1324 StringRef MacroName =
T->getMacroIdentifier()->getName();
1325 OS << MacroName <<
" ";
1329 printBefore(
T->getModifiedType(), OS);
1332void TypePrinter::printMacroQualifiedAfter(
const MacroQualifiedType *
T,
1334 printAfter(
T->getModifiedType(), OS);
1337void TypePrinter::printTypedefAfter(
const TypedefType *
T, raw_ostream &OS) {}
1339void TypePrinter::printTypeOfExprBefore(
const TypeOfExprType *
T,
1341 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual "
1343 if (
T->getUnderlyingExpr())
1344 T->getUnderlyingExpr()->printPretty(OS,
nullptr, Policy);
1345 spaceBeforePlaceHolder(OS);
1348void TypePrinter::printTypeOfExprAfter(
const TypeOfExprType *
T,
1351void TypePrinter::printTypeOfBefore(
const TypeOfType *
T, raw_ostream &OS) {
1352 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual("
1354 print(
T->getUnmodifiedType(), OS, StringRef());
1356 spaceBeforePlaceHolder(OS);
1359void TypePrinter::printTypeOfAfter(
const TypeOfType *
T, raw_ostream &OS) {}
1361void TypePrinter::printDecltypeBefore(
const DecltypeType *
T, raw_ostream &OS) {
1367 if (
const Expr *E =
T->getUnderlyingExpr()) {
1368 PrintingPolicy ExprPolicy = Policy;
1370 E->printPretty(OS,
nullptr, ExprPolicy);
1373 spaceBeforePlaceHolder(OS);
1376void TypePrinter::printPackIndexingBefore(
const PackIndexingType *
T,
1378 if (
T->hasSelectedType()) {
1379 OS <<
T->getSelectedType();
1381 OS <<
T->getPattern() <<
"...[";
1382 T->getIndexExpr()->printPretty(OS,
nullptr, Policy);
1385 spaceBeforePlaceHolder(OS);
1388void TypePrinter::printPackIndexingAfter(
const PackIndexingType *
T,
1391void TypePrinter::printDecltypeAfter(
const DecltypeType *
T, raw_ostream &OS) {
1396void TypePrinter::printUnaryTransformBefore(
const UnaryTransformType *
T,
1398 IncludeStrongLifetimeRAII Strong(Policy);
1400 static const llvm::DenseMap<int, const char *> Transformation = {{
1401#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1402 {UnaryTransformType::Enum, "__" #Trait},
1403#include "clang/Basic/BuiltinTraits.inc"
1405 OS << Transformation.lookup(
T->getUTTKind()) <<
'(';
1406 print(
T->getBaseType(), OS, StringRef());
1408 spaceBeforePlaceHolder(OS);
1411void TypePrinter::printUnaryTransformAfter(
const UnaryTransformType *
T,
1414void TypePrinter::printAutoBefore(
const AutoType *
T, raw_ostream &OS) {
1416 if (!
T->getDeducedType().isNull()) {
1417 printBefore(
T->getDeducedType(), OS);
1419 if (
T->isConstrained()) {
1423 Concept.print(OS, Policy, TemplateName::Qualified::None);
1424 auto Args =
T->getTypeConstraintArguments();
1425 if (!Args.empty()) {
1426 const TemplateDecl *TD =
Concept.getAsTemplateDecl();
1428 TD =
Concept.getAsTemplateTemplateParmDecl();
1429 printTemplateArgumentList(OS, Args, Policy,
1434 switch (
T->getKeyword()) {
1435 case AutoTypeKeyword::Auto:
OS <<
"auto";
break;
1436 case AutoTypeKeyword::DecltypeAuto:
OS <<
"decltype(auto)";
break;
1437 case AutoTypeKeyword::GNUAutoType:
OS <<
"__auto_type";
break;
1439 spaceBeforePlaceHolder(OS);
1443void TypePrinter::printAutoAfter(
const AutoType *
T, raw_ostream &OS) {
1445 if (!
T->getDeducedType().isNull())
1446 printAfter(
T->getDeducedType(), OS);
1449void TypePrinter::printDeducedTemplateSpecializationBefore(
1450 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1452 T->getKeyword() != ElaboratedTypeKeyword::None)
1462 ArrayRef<TemplateArgument> Args;
1463 TemplateDecl *DeducedTD =
nullptr;
1464 if (!
T->getDeducedType().isNull()) {
1465 if (
const auto *TST =
1466 dyn_cast<TemplateSpecializationType>(
T->getDeducedType())) {
1467 DeducedTD = TST->getTemplateName().getAsTemplateDecl(
1469 Args = TST->template_arguments();
1474 DeducedTD = CD->getSpecializedTemplate();
1475 Args = CD->getTemplateArgs().asArray();
1489 IncludeStrongLifetimeRAII Strong(Policy);
1490 Name.
print(OS, Policy);
1493 printTemplateArgumentList(OS, Args, Policy,
1497 spaceBeforePlaceHolder(OS);
1500void TypePrinter::printDeducedTemplateSpecializationAfter(
1501 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1503 if (!
T->getDeducedType().isNull())
1504 printAfter(
T->getDeducedType(), OS);
1507void TypePrinter::printAtomicBefore(
const AtomicType *
T, raw_ostream &OS) {
1508 IncludeStrongLifetimeRAII Strong(Policy);
1511 print(
T->getValueType(), OS, StringRef());
1513 spaceBeforePlaceHolder(OS);
1516void TypePrinter::printAtomicAfter(
const AtomicType *
T, raw_ostream &OS) {}
1518void TypePrinter::printPipeBefore(
const PipeType *
T, raw_ostream &OS) {
1519 IncludeStrongLifetimeRAII Strong(Policy);
1521 if (
T->isReadOnly())
1524 OS <<
"write_only ";
1526 print(
T->getElementType(), OS, StringRef());
1527 spaceBeforePlaceHolder(OS);
1530void TypePrinter::printPipeAfter(
const PipeType *
T, raw_ostream &OS) {}
1532void TypePrinter::printBitIntBefore(
const BitIntType *
T, raw_ostream &OS) {
1533 if (
T->isUnsigned())
1535 OS <<
"_BitInt(" <<
T->getNumBits() <<
")";
1536 spaceBeforePlaceHolder(OS);
1539void TypePrinter::printBitIntAfter(
const BitIntType *
T, raw_ostream &OS) {}
1541void TypePrinter::printDependentBitIntBefore(
const DependentBitIntType *
T,
1543 if (
T->isUnsigned())
1546 T->getNumBitsExpr()->printPretty(OS,
nullptr, Policy);
1548 spaceBeforePlaceHolder(OS);
1551void TypePrinter::printDependentBitIntAfter(
const DependentBitIntType *
T,
1554void TypePrinter::printPredefinedSugarBefore(
const PredefinedSugarType *
T,
1556 OS <<
T->getIdentifier()->getName();
1557 spaceBeforePlaceHolder(OS);
1560void TypePrinter::printPredefinedSugarAfter(
const PredefinedSugarType *
T,
1563void TypePrinter::printTagType(
const TagType *
T, raw_ostream &OS) {
1564 TagDecl *D =
T->getDecl();
1567 D->
print(OS, Policy, Indentation);
1568 spaceBeforePlaceHolder(OS);
1572 bool PrintedKindDecoration =
false;
1575 PrintedKindDecoration =
true;
1580 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1581 if (
T->getKeyword() != ElaboratedTypeKeyword::None) {
1582 PrintedKindDecoration =
true;
1588 T->getQualifier().print(OS, Policy);
1599 clang::PrintingPolicy
Copy(Policy);
1602 if (PrintedKindDecoration) {
1603 Copy.SuppressTagKeywordInAnonNames =
true;
1604 Copy.SuppressTagKeyword =
true;
1612 if (
auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1613 const TemplateParameterList *TParams =
1614 S->getSpecializedTemplate()->getTemplateParameters();
1615 const ASTTemplateArgumentListInfo *TArgAsWritten =
1616 S->getTemplateArgsAsWritten();
1617 IncludeStrongLifetimeRAII Strong(Policy);
1618 if (TArgAsWritten && !Policy.PrintAsCanonical)
1619 printTemplateArgumentList(OS, TArgAsWritten->
arguments(), Policy,
1622 printTemplateArgumentList(OS, S->getTemplateArgs().asArray(), Policy,
1626 spaceBeforePlaceHolder(OS);
1629void TypePrinter::printRecordBefore(
const RecordType *
T, raw_ostream &OS) {
1631 if (Policy.UsePreferredNames) {
1632 for (
const auto *PNA :
T->getDecl()
1633 ->getMostRecentDecl()
1634 ->specific_attrs<PreferredNameAttr>()) {
1639 QualType
T = PNA->getTypedefType();
1641 if (
auto *TT = dyn_cast<TypedefType>(
T))
1642 return printTypeSpec(TT->getDecl(), OS);
1643 if (
auto *TST = dyn_cast<TemplateSpecializationType>(
T))
1644 return printTemplateId(TST, OS,
true);
1650 printTagType(
T, OS);
1653void TypePrinter::printRecordAfter(
const RecordType *
T, raw_ostream &OS) {}
1655void TypePrinter::printEnumBefore(
const EnumType *
T, raw_ostream &OS) {
1656 printTagType(
T, OS);
1659void TypePrinter::printEnumAfter(
const EnumType *
T, raw_ostream &OS) {}
1661void TypePrinter::printInjectedClassNameBefore(
const InjectedClassNameType *
T,
1663 const ASTContext &Ctx =
T->getDecl()->getASTContext();
1664 IncludeStrongLifetimeRAII Strong(Policy);
1665 T->getTemplateName(Ctx).print(OS, Policy);
1666 if (Policy.PrintInjectedClassNameWithArguments) {
1667 auto *
Decl =
T->getDecl();
1670 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(Decl)) {
1671 printTemplateArgumentList(OS, RD->getTemplateArgsAsWritten()->arguments(),
1673 T->getTemplateDecl()->getTemplateParameters());
1675 ClassTemplateDecl *TD =
Decl->getDescribedClassTemplate();
1677 printTemplateArgumentList(
1679 T->getTemplateDecl()->getTemplateParameters());
1682 spaceBeforePlaceHolder(OS);
1685void TypePrinter::printInjectedClassNameAfter(
const InjectedClassNameType *
T,
1688void TypePrinter::printTemplateTypeParmBefore(
const TemplateTypeParmType *
T,
1690 TemplateTypeParmDecl *D =
T->getDecl();
1693 TC->print(OS, Policy);
1697 }
else if (IdentifierInfo *Id =
T->getIdentifier())
1698 OS << (Policy.CleanUglifiedParameters ? Id->deuglifiedName()
1701 OS <<
"type-parameter-" <<
T->getDepth() <<
'-' <<
T->getIndex();
1703 spaceBeforePlaceHolder(OS);
1706void TypePrinter::printTemplateTypeParmAfter(
const TemplateTypeParmType *
T,
1709void TypePrinter::printSubstTemplateTypeParmBefore(
1710 const SubstTemplateTypeParmType *
T,
1712 IncludeStrongLifetimeRAII Strong(Policy);
1713 printBefore(
T->getReplacementType(), OS);
1716void TypePrinter::printSubstTemplateTypeParmAfter(
1717 const SubstTemplateTypeParmType *
T,
1719 IncludeStrongLifetimeRAII Strong(Policy);
1720 printAfter(
T->getReplacementType(), OS);
1723void TypePrinter::printSubstBuiltinTemplatePackBefore(
1724 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {
1725 IncludeStrongLifetimeRAII Strong(Policy);
1729void TypePrinter::printSubstBuiltinTemplatePackAfter(
1730 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {}
1732void TypePrinter::printSubstTemplateTypeParmPackBefore(
1733 const SubstTemplateTypeParmPackType *
T,
1735 IncludeStrongLifetimeRAII Strong(Policy);
1736 if (
const TemplateTypeParmDecl *D =
T->getReplacedParameter()) {
1739 TC->print(OS, Policy);
1744 OS << (Policy.CleanUglifiedParameters ? Id->deuglifiedName()
1749 spaceBeforePlaceHolder(OS);
1753void TypePrinter::printSubstTemplateTypeParmPackAfter(
1754 const SubstTemplateTypeParmPackType *
T,
1756 IncludeStrongLifetimeRAII Strong(Policy);
1759void TypePrinter::printTemplateId(
const TemplateSpecializationType *
T,
1760 raw_ostream &OS,
bool FullyQualify) {
1761 IncludeStrongLifetimeRAII Strong(Policy);
1764 K != ElaboratedTypeKeyword::None)
1765 OS << TypeWithKeyword::getKeywordName(K) <<
' ';
1768 T->getTemplateName().getAsTemplateDecl(
true);
1770 if (FullyQualify && TD) {
1776 T->getTemplateName().print(OS, Policy,
1778 ? TemplateName::Qualified::AsWritten
1779 : TemplateName::Qualified::None);
1782 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1784 printTemplateArgumentList(OS,
T->template_arguments(), Policy, TPL);
1785 spaceBeforePlaceHolder(OS);
1788void TypePrinter::printTemplateSpecializationBefore(
1789 const TemplateSpecializationType *
T,
1791 printTemplateId(
T, OS, Policy.FullyQualifiedName);
1794void TypePrinter::printTemplateSpecializationAfter(
1795 const TemplateSpecializationType *
T,
1798void TypePrinter::printParenBefore(
const ParenType *
T, raw_ostream &OS) {
1800 printBefore(
T->getInnerType(), OS);
1803 printBefore(
T->getInnerType(), OS);
1806void TypePrinter::printParenAfter(
const ParenType *
T, raw_ostream &OS) {
1809 printAfter(
T->getInnerType(), OS);
1811 printAfter(
T->getInnerType(), OS);
1814void TypePrinter::printDependentNameBefore(
const DependentNameType *
T,
1816 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1817 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1819 T->getQualifier().print(OS, Policy);
1820 OS <<
T->getIdentifier()->getName();
1821 spaceBeforePlaceHolder(OS);
1824void TypePrinter::printDependentNameAfter(
const DependentNameType *
T,
1827void TypePrinter::printPackExpansionBefore(
const PackExpansionType *
T,
1829 printBefore(
T->getPattern(), OS);
1832void TypePrinter::printPackExpansionAfter(
const PackExpansionType *
T,
1834 printAfter(
T->getPattern(), OS);
1842 if (
T->isCountInBytes() &&
T->isOrNull())
1843 OS <<
"__sized_by_or_null(";
1844 else if (
T->isCountInBytes())
1845 OS <<
"__sized_by(";
1846 else if (
T->isOrNull())
1847 OS <<
"__counted_by_or_null(";
1849 OS <<
"__counted_by(";
1850 if (
T->getCountExpr())
1851 T->getCountExpr()->printPretty(OS,
nullptr, Policy);
1855void TypePrinter::printCountAttributedBefore(
const CountAttributedType *
T,
1862void TypePrinter::printCountAttributedAfter(
const CountAttributedType *
T,
1869void TypePrinter::printLateParsedAttrBefore(
const LateParsedAttrType *
T,
1873 printBefore(
T->getWrappedType(), OS);
1876void TypePrinter::printLateParsedAttrAfter(
const LateParsedAttrType *
T,
1880 printAfter(
T->getWrappedType(), OS);
1883void TypePrinter::printAttributedBefore(
const AttributedType *
T,
1888 if (
T->getAttrKind() == attr::ObjCGC ||
1889 T->getAttrKind() == attr::ObjCOwnership)
1890 return printBefore(
T->getEquivalentType(), OS);
1892 if (
T->getAttrKind() == attr::ObjCKindOf)
1895 if (
T->getAttrKind() == attr::PreserveNone) {
1896 OS <<
"__attribute__((preserve_none)) ";
1897 spaceBeforePlaceHolder(OS);
1898 }
else if (
T->getAttrKind() == attr::PreserveMost) {
1899 OS <<
"__attribute__((preserve_most)) ";
1900 spaceBeforePlaceHolder(OS);
1901 }
else if (
T->getAttrKind() == attr::PreserveAll) {
1902 OS <<
"__attribute__((preserve_all)) ";
1903 spaceBeforePlaceHolder(OS);
1906 if (
T->getAttrKind() == attr::AddressSpace)
1907 printBefore(
T->getEquivalentType(), OS);
1909 printBefore(
T->getModifiedType(), OS);
1911 if (
T->isMSTypeSpec()) {
1912 switch (
T->getAttrKind()) {
1914 case attr::Ptr32:
OS <<
" __ptr32";
break;
1915 case attr::Ptr64:
OS <<
" __ptr64";
break;
1916 case attr::SPtr:
OS <<
" __sptr";
break;
1917 case attr::UPtr:
OS <<
" __uptr";
break;
1919 spaceBeforePlaceHolder(OS);
1922 if (
T->isWebAssemblyFuncrefSpec())
1926 if (
T->getImmediateNullability()) {
1927 if (
T->getAttrKind() == attr::TypeNonNull)
1929 else if (
T->getAttrKind() == attr::TypeNullable)
1931 else if (
T->getAttrKind() == attr::TypeNullUnspecified)
1932 OS <<
" _Null_unspecified";
1933 else if (
T->getAttrKind() == attr::TypeNullableResult)
1934 OS <<
" _Nullable_result";
1936 llvm_unreachable(
"unhandled nullability");
1937 spaceBeforePlaceHolder(OS);
1941void TypePrinter::printAttributedAfter(
const AttributedType *
T,
1946 if (
T->getAttrKind() == attr::ObjCGC ||
1947 T->getAttrKind() == attr::ObjCOwnership)
1948 return printAfter(
T->getEquivalentType(), OS);
1952 SaveAndRestore MaybeSuppressCC(InsideCCAttribute,
T->isCallingConv());
1954 printAfter(
T->getModifiedType(), OS);
1958 if (
T->getAttrKind() == attr::ObjCKindOf ||
T->isMSTypeSpec() ||
1959 T->getImmediateNullability() ||
T->isWebAssemblyFuncrefSpec())
1963 if (
T->getAttrKind() == attr::ObjCInertUnsafeUnretained)
1967 if (
T->getAttrKind() == attr::NSReturnsRetained &&
1968 !
T->getEquivalentType()->
castAs<FunctionType>()
1969 ->getExtInfo().getProducesResult())
1972 if (
T->getAttrKind() == attr::LifetimeBound) {
1973 OS <<
" [[clang::lifetimebound]]";
1976 if (
T->getAttrKind() == attr::LifetimeCaptureBy) {
1977 OS <<
" [[clang::lifetime_capture_by(";
1978 if (
auto *attr = dyn_cast_or_null<LifetimeCaptureByAttr>(
T->getAttr()))
1979 llvm::interleaveComma(
attr->getArgIdents(), OS,
1980 [&](
auto it) { OS << it->getName(); });
1988 if (
T->getAttrKind() == attr::AddressSpace)
1991 if (
T->getAttrKind() == attr::AnnotateType) {
1996 OS <<
" [[clang::annotate_type(...)]]";
2000 if (
T->getAttrKind() == attr::ArmStreaming) {
2001 OS <<
"__arm_streaming";
2004 if (
T->getAttrKind() == attr::ArmStreamingCompatible) {
2005 OS <<
"__arm_streaming_compatible";
2009 if (
T->getAttrKind() == attr::SwiftAttr) {
2010 if (
auto *swiftAttr = dyn_cast_or_null<SwiftAttrAttr>(
T->getAttr())) {
2011 OS <<
" __attribute__((swift_attr(\"" << swiftAttr->getAttribute()
2017 if (
T->getAttrKind() == attr::PreserveAll ||
2018 T->getAttrKind() == attr::PreserveMost ||
2019 T->getAttrKind() == attr::PreserveNone) {
2024 OS <<
" __attribute__((";
2025 switch (
T->getAttrKind()) {
2026#define TYPE_ATTR(NAME)
2027#define DECL_OR_TYPE_ATTR(NAME)
2028#define ATTR(NAME) case attr::NAME:
2029#include "clang/Basic/AttrList.inc"
2030 llvm_unreachable(
"non-type attribute attached to type");
2032 case attr::BTFTypeTag:
2033 llvm_unreachable(
"BTFTypeTag attribute handled separately");
2035 case attr::HLSLResourceClass:
2036 case attr::HLSLIsROV:
2037 case attr::HLSLRawBuffer:
2038 case attr::HLSLContainedType:
2039 case attr::HLSLIsCounter:
2040 case attr::HLSLResourceDimension:
2041 case attr::HLSLIsArray:
2042 case attr::HLSLIsMultiSampled:
2043 llvm_unreachable(
"HLSL resource type attributes handled separately");
2045 case attr::OpenCLPrivateAddressSpace:
2046 case attr::OpenCLGlobalAddressSpace:
2047 case attr::OpenCLGlobalDeviceAddressSpace:
2048 case attr::OpenCLGlobalHostAddressSpace:
2049 case attr::OpenCLLocalAddressSpace:
2050 case attr::OpenCLConstantAddressSpace:
2051 case attr::OpenCLGenericAddressSpace:
2052 case attr::HLSLGroupSharedAddressSpace:
2053 case attr::SYCLPrivateAddressSpace:
2054 case attr::SYCLGlobalAddressSpace:
2055 case attr::SYCLLocalAddressSpace:
2056 case attr::SYCLConstantAddressSpace:
2057 case attr::SYCLGenericAddressSpace:
2060 llvm_unreachable(
"Address space attributes handled separately");
2061 case attr::CountedBy:
2062 case attr::CountedByOrNull:
2064 case attr::SizedByOrNull:
2065 case attr::LifetimeBound:
2066 case attr::LifetimeCaptureBy:
2067 case attr::TypeNonNull:
2068 case attr::TypeNullable:
2069 case attr::TypeNullableResult:
2070 case attr::TypeNullUnspecified:
2072 case attr::ObjCInertUnsafeUnretained:
2073 case attr::ObjCKindOf:
2074 case attr::ObjCOwnership:
2079 case attr::PointerAuth:
2080 case attr::AddressSpace:
2081 case attr::CmseNSCall:
2082 case attr::AnnotateType:
2083 case attr::WebAssemblyFuncref:
2084 case attr::ArmAgnostic:
2085 case attr::ArmStreaming:
2086 case attr::ArmStreamingCompatible:
2089 case attr::ArmInOut:
2090 case attr::ArmPreserves:
2091 case attr::NonBlocking:
2092 case attr::NonAllocating:
2093 case attr::Blocking:
2094 case attr::Allocating:
2095 case attr::SwiftAttr:
2096 case attr::PreserveAll:
2097 case attr::PreserveMost:
2098 case attr::PreserveNone:
2099 case attr::OverflowBehavior:
2100 llvm_unreachable(
"This attribute should have been handled already");
2102 case attr::NSReturnsRetained:
2103 OS <<
"ns_returns_retained";
2106 case attr::HLSLRowMajor:
2109 case attr::HLSLColumnMajor:
2110 OS <<
"column_major";
2115 case attr::AnyX86NoCfCheck:
OS <<
"nocf_check";
break;
2116 case attr::CDecl:
OS <<
"cdecl";
break;
2117 case attr::FastCall:
OS <<
"fastcall";
break;
2118 case attr::StdCall:
OS <<
"stdcall";
break;
2119 case attr::ThisCall:
OS <<
"thiscall";
break;
2120 case attr::SwiftCall:
OS <<
"swiftcall";
break;
2121 case attr::SwiftAsyncCall:
OS <<
"swiftasynccall";
break;
2122 case attr::VectorCall:
OS <<
"vectorcall";
break;
2123 case attr::Pascal:
OS <<
"pascal";
break;
2124 case attr::MSABI:
OS <<
"ms_abi";
break;
2125 case attr::SysVABI:
OS <<
"sysv_abi";
break;
2126 case attr::RegCall:
OS <<
"regcall";
break;
2129 QualType t =
T->getEquivalentType();
2133 "\"aapcs\"" :
"\"aapcs-vfp\"");
2137 case attr::AArch64VectorPcs:
OS <<
"aarch64_vector_pcs";
break;
2138 case attr::AArch64SVEPcs:
OS <<
"aarch64_sve_pcs";
break;
2139 case attr::IntelOclBicc:
2140 OS <<
"inteloclbicc";
2145 case attr::RISCVVectorCC:
2146 OS <<
"riscv_vector_cc";
2148 case attr::RISCVVLSCC:
2149 OS <<
"riscv_vls_cc";
2154 case attr::CFIUncheckedCallee:
2155 OS <<
"cfi_unchecked_callee";
2157 case attr::AcquireHandle:
2158 OS <<
"acquire_handle";
2160 case attr::ArmMveStrictPolymorphism:
2161 OS <<
"__clang_arm_mve_strict_polymorphism";
2163 case attr::ExtVectorType:
2164 OS <<
"ext_vector_type";
2169 case attr::NoFieldProtection:
2170 OS <<
"no_field_protection";
2172 case attr::PointerFieldProtection:
2173 OS <<
"pointer_field_protection";
2179void TypePrinter::printBTFTagAttributedBefore(
const BTFTagAttributedType *
T,
2181 printBefore(
T->getWrappedType(), OS);
2182 OS <<
" __attribute__((btf_type_tag(\"" <<
T->getAttr()->getBTFTypeTag() <<
"\")))";
2185void TypePrinter::printBTFTagAttributedAfter(
const BTFTagAttributedType *
T,
2187 printAfter(
T->getWrappedType(), OS);
2190void TypePrinter::printOverflowBehaviorBefore(
const OverflowBehaviorType *
T,
2192 switch (
T->getBehaviorKind()) {
2193 case clang::OverflowBehaviorType::OverflowBehaviorKind::Wrap:
2196 case clang::OverflowBehaviorType::OverflowBehaviorKind::Trap:
2200 printBefore(
T->getUnderlyingType(), OS);
2203void TypePrinter::printOverflowBehaviorAfter(
const OverflowBehaviorType *
T,
2205 printAfter(
T->getUnderlyingType(), OS);
2208void TypePrinter::printHLSLAttributedResourceBefore(
2209 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2210 printBefore(
T->getWrappedType(), OS);
2213void TypePrinter::printHLSLAttributedResourceAfter(
2214 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2215 printAfter(
T->getWrappedType(), OS);
2216 const HLSLAttributedResourceType::Attributes &Attrs =
T->getAttrs();
2217 OS <<
" [[hlsl::resource_class(\""
2218 << HLSLResourceClassAttr::ConvertResourceClassToStr(Attrs.ResourceClass)
2221 OS <<
" [[hlsl::is_rov]]";
2222 if (Attrs.RawBuffer)
2223 OS <<
" [[hlsl::raw_buffer]]";
2224 if (Attrs.IsCounter)
2225 OS <<
" [[hlsl::is_counter]]";
2227 OS <<
" [[hlsl::is_array]]";
2228 if (Attrs.isMultiSampled())
2229 OS <<
" [[hlsl::is_ms]]";
2231 QualType ContainedTy =
T->getContainedType();
2232 if (!ContainedTy.
isNull()) {
2233 OS <<
" [[hlsl::contained_type(";
2234 printBefore(ContainedTy, OS);
2235 printAfter(ContainedTy, OS);
2239 if (Attrs.ResourceDimension != llvm::dxil::ResourceDimension::Unknown)
2240 OS <<
" [[hlsl::dimension(\""
2241 << HLSLResourceDimensionAttr::ConvertResourceDimensionToStr(
2242 Attrs.ResourceDimension)
2246void TypePrinter::printHLSLInlineSpirvBefore(
const HLSLInlineSpirvType *
T,
2248 OS <<
"__hlsl_spirv_type<" <<
T->getOpcode();
2250 OS <<
", " <<
T->getSize();
2251 OS <<
", " <<
T->getAlignment();
2253 for (
auto &Operand :
T->getOperands()) {
2254 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2258 case SpirvOperandKind::ConstantId: {
2259 QualType ConstantType =
Operand.getResultType();
2260 OS <<
"vk::integral_constant<";
2261 printBefore(ConstantType, OS);
2262 printAfter(ConstantType, OS);
2268 case SpirvOperandKind::Literal:
2269 OS <<
"vk::Literal<vk::integral_constant<uint, ";
2273 case SpirvOperandKind::TypeId: {
2275 printBefore(
Type, OS);
2276 printAfter(
Type, OS);
2280 llvm_unreachable(
"Invalid SpirvOperand kind!");
2288void TypePrinter::printHLSLInlineSpirvAfter(
const HLSLInlineSpirvType *
T,
2293void TypePrinter::printObjCInterfaceBefore(
const ObjCInterfaceType *
T,
2295 OS <<
T->getDecl()->getName();
2296 spaceBeforePlaceHolder(OS);
2299void TypePrinter::printObjCInterfaceAfter(
const ObjCInterfaceType *
T,
2302void TypePrinter::printObjCTypeParamBefore(
const ObjCTypeParamType *
T,
2304 OS <<
T->getDecl()->getName();
2305 if (!
T->qual_empty()) {
2306 bool isFirst =
true;
2308 for (
const auto *I :
T->quals()) {
2318 spaceBeforePlaceHolder(OS);
2321void TypePrinter::printObjCTypeParamAfter(
const ObjCTypeParamType *
T,
2324void TypePrinter::printObjCObjectBefore(
const ObjCObjectType *
T,
2326 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2327 !
T->isKindOfTypeAsWritten())
2328 return printBefore(
T->getBaseType(), OS);
2330 if (
T->isKindOfTypeAsWritten())
2333 print(
T->getBaseType(), OS, StringRef());
2335 if (
T->isSpecializedAsWritten()) {
2336 bool isFirst =
true;
2338 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
2344 print(typeArg, OS, StringRef());
2349 if (!
T->qual_empty()) {
2350 bool isFirst =
true;
2352 for (
const auto *I :
T->quals()) {
2362 spaceBeforePlaceHolder(OS);
2365void TypePrinter::printObjCObjectAfter(
const ObjCObjectType *
T,
2367 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2368 !
T->isKindOfTypeAsWritten())
2369 return printAfter(
T->getBaseType(), OS);
2372void TypePrinter::printObjCObjectPointerBefore(
const ObjCObjectPointerType *
T,
2379 if (HasEmptyPlaceHolder)
2385void TypePrinter::printObjCObjectPointerAfter(
const ObjCObjectPointerType *
T,
2396 llvm::raw_ostream &OS,
bool IncludeType) {
2397 A.
print(PP, OS, IncludeType);
2410 TemplateArgument Pattern,
2411 ArrayRef<TemplateArgument> Args,
2420 if (
auto *TTPT = Pattern->
getAsCanonical<TemplateTypeParmType>()) {
2421 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2424 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2436 if (TQual != PatQual)
2441 QualType TPointee =
T->getPointeeType();
2453 if (
auto *TTST =
T->getAs<TemplateSpecializationType>()) {
2454 Template = TTST->getTemplateName();
2455 TemplateArgs = TTST->template_arguments();
2456 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2457 T->getAsCXXRecordDecl())) {
2459 TemplateArgs = CTSD->getTemplateArgs().asArray();
2467 if (TemplateArgs.size() != PTST->template_arguments().size())
2469 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2471 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2522 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2523 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2524 Args[NTTP->getIndex()].structurallyEquals(Arg);
2540 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2541 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2550bool clang::isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
2551 const NamedDecl *Param,
2552 ArrayRef<TemplateArgument> Args,
2558 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2559 return TTPD->hasDefaultArgument() &&
2561 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2562 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2563 return TTPD->hasDefaultArgument() &&
2565 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2566 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2567 return NTTPD->hasDefaultArgument() &&
2569 Ctx, Arg, NTTPD->getDefaultArgument().getArgument(), Args,
2575template <
typename TA>
2581 !Args.empty() && !IsPack && Args.size() <= TPL->
size()) {
2583 for (
const TA &A : Args)
2585 while (!Args.empty() &&
getArgument(Args.back()).getIsDefaulted())
2586 Args = Args.drop_back();
2589 const char *Comma = Policy.MSVCFormatting ?
"," :
", ";
2593 bool NeedSpace =
false;
2594 bool FirstArg =
true;
2595 for (
const auto &Arg : Args) {
2598 llvm::raw_svector_ostream ArgOS(Buf);
2611 Policy, TPL, ParmIndex));
2613 StringRef ArgString = ArgOS.str();
2618 if (FirstArg && ArgString.starts_with(
":"))
2625 if (!ArgString.empty()) {
2642void clang::printTemplateArgumentList(raw_ostream &OS,
2643 const TemplateArgumentListInfo &Args,
2644 const PrintingPolicy &Policy,
2645 const TemplateParameterList *TPL) {
2646 printTemplateArgumentList(OS, Args.
arguments(), Policy, TPL);
2649void clang::printTemplateArgumentList(raw_ostream &OS,
2650 ArrayRef<TemplateArgument> Args,
2651 const PrintingPolicy &Policy,
2652 const TemplateParameterList *TPL) {
2653 PrintingPolicy InnerPolicy = Policy;
2655 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2658void clang::printTemplateArgumentList(raw_ostream &OS,
2659 ArrayRef<TemplateArgumentLoc> Args,
2660 const PrintingPolicy &Policy,
2661 const TemplateParameterList *TPL) {
2662 PrintingPolicy InnerPolicy = Policy;
2664 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2674 llvm::raw_svector_ostream StrOS(Buf);
2676 return StrOS.str().str();
2704 llvm::raw_svector_ostream StrOS(Buf);
2705 print(StrOS, Policy);
2706 return std::string(StrOS.str());
2724 PointerAuth && !PointerAuth.isEmptyWhenPrinted(Policy))
2741 return "__constant";
2748 return "__global_device";
2751 return "__global_host";
2753 return "[[clang::sycl_global]]";
2755 return "[[clang::sycl_local]]";
2757 return "[[clang::sycl_private]]";
2759 return "[[clang::sycl_generic]]";
2761 return "[[clang::sycl_constant]]";
2763 return "__device__";
2765 return "__constant__";
2767 return "__shared__";
2769 return "__sptr __ptr32";
2771 return "__uptr __ptr32";
2775 return "groupshared";
2777 return "hlsl_constant";
2779 return "hlsl_private";
2781 return "hlsl_device";
2783 return "hlsl_input";
2785 return "hlsl_output";
2787 return "hlsl_push_constant";
2791 return "amdgpu_barrier";
2801 bool appendSpaceIfNonEmpty)
const {
2802 bool addSpace =
false;
2812 OS <<
"__unaligned";
2816 if (!ASStr.empty()) {
2822 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2861 PointerAuth.print(OS, Policy);
2864 if (appendSpaceIfNonEmpty && addSpace)
2886 const Twine &PlaceHolder,
unsigned Indentation)
const {
2893 const Twine &PlaceHolder,
unsigned Indentation) {
2895 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2897 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2907 std::string &buffer,
2910 llvm::raw_svector_ostream StrOS(Buf);
2911 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2912 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, const Context &Ctx, 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 ...
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
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...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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.
void printNestedNameSpecifier(raw_ostream &OS) const
Print only the nested name specifier part of a fully-qualified name, including the '::' at the end.
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
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.
StringRef getKindName() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
ArrayRef< TemplateArgumentLoc > arguments() const
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.
Top level wrappers for InstallAPI frontend operations.
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.
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.
@ Concept
The name was classified as a concept name.
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)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
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 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 UseVoidForZeroParams
Whether we should use '(void)' rather than '()' for a function prototype with zero parameters.
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned Restrict
Whether we can use 'restrict' rather than '__restrict'.
unsigned UseHLSLTypes
Whether or not we're printing known HLSL code and should print HLSL sugared types when possible.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
unsigned ResolveDecltype
Use whitespace and punctuation like MSVC does.
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.