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)
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::BTFTagAttributed:
246 case Type::HLSLAttributedResource:
247 case Type::HLSLInlineSpirv:
248 case Type::PredefinedSugar:
249 CanPrefixQualifiers =
true;
252 case Type::ObjCObjectPointer:
257 case Type::VariableArray:
258 case Type::DependentSizedArray:
259 NeedARCStrongQualifier =
true;
262 case Type::ConstantArray:
263 case Type::IncompleteArray:
264 return canPrefixQualifiers(
266 NeedARCStrongQualifier);
270 case Type::ArrayParameter:
272 case Type::BlockPointer:
273 case Type::LValueReference:
274 case Type::RValueReference:
275 case Type::MemberPointer:
276 case Type::DependentAddressSpace:
277 case Type::DependentVector:
278 case Type::DependentSizedExtVector:
280 case Type::ExtVector:
281 case Type::ConstantMatrix:
282 case Type::DependentSizedMatrix:
283 case Type::FunctionProto:
284 case Type::FunctionNoProto:
286 case Type::PackExpansion:
287 case Type::SubstTemplateTypeParm:
288 case Type::MacroQualified:
289 case Type::CountAttributed:
290 CanPrefixQualifiers =
false;
293 case Type::Attributed: {
297 CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace;
300 case Type::PackIndexing: {
301 return canPrefixQualifiers(
303 NeedARCStrongQualifier);
307 return CanPrefixQualifiers;
310void TypePrinter::printBefore(QualType
T, raw_ostream &OS) {
315 Qualifiers Quals =
Split.Quals;
316 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
Split.Ty))
317 Quals -= QualType(Subst, 0).getQualifiers();
319 printBefore(
Split.Ty, Quals, OS);
324void TypePrinter::printBefore(
const Type *
T,Qualifiers Quals, raw_ostream &OS) {
328 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
332 bool CanPrefixQualifiers =
false;
333 bool NeedARCStrongQualifier =
false;
334 CanPrefixQualifiers = canPrefixQualifiers(
T, NeedARCStrongQualifier);
336 if (CanPrefixQualifiers && !Quals.
empty()) {
337 if (NeedARCStrongQualifier) {
338 IncludeStrongLifetimeRAII Strong(Policy);
339 Quals.
print(OS, Policy,
true);
341 Quals.
print(OS, Policy,
true);
345 bool hasAfterQuals =
false;
346 if (!CanPrefixQualifiers && !Quals.
empty()) {
349 HasEmptyPlaceHolder =
false;
353#define ABSTRACT_TYPE(CLASS, PARENT)
354#define TYPE(CLASS, PARENT) case Type::CLASS: \
355 print##CLASS##Before(cast<CLASS##Type>(T), OS); \
357#include "clang/AST/TypeNodes.inc"
361 if (NeedARCStrongQualifier) {
362 IncludeStrongLifetimeRAII Strong(Policy);
363 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
365 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
370void TypePrinter::printAfter(QualType t, raw_ostream &OS) {
372 printAfter(split.
Ty, split.
Quals, OS);
377void TypePrinter::printAfter(
const Type *
T, Qualifiers Quals, raw_ostream &OS) {
379#define ABSTRACT_TYPE(CLASS, PARENT)
380#define TYPE(CLASS, PARENT) case Type::CLASS: \
381 print##CLASS##After(cast<CLASS##Type>(T), OS); \
383#include "clang/AST/TypeNodes.inc"
387void TypePrinter::printBuiltinBefore(
const BuiltinType *
T, raw_ostream &OS) {
388 OS <<
T->getName(Policy);
389 spaceBeforePlaceHolder(OS);
392void TypePrinter::printBuiltinAfter(
const BuiltinType *
T, raw_ostream &OS) {}
394void TypePrinter::printComplexBefore(
const ComplexType *
T, raw_ostream &OS) {
396 printBefore(
T->getElementType(), OS);
399void TypePrinter::printComplexAfter(
const ComplexType *
T, raw_ostream &OS) {
400 printAfter(
T->getElementType(), OS);
403void TypePrinter::printPointerBefore(
const PointerType *
T, raw_ostream &OS) {
404 IncludeStrongLifetimeRAII Strong(Policy);
405 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
414void TypePrinter::printPointerAfter(
const PointerType *
T, raw_ostream &OS) {
415 IncludeStrongLifetimeRAII Strong(Policy);
416 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
424void TypePrinter::printBlockPointerBefore(
const BlockPointerType *
T,
426 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
431void TypePrinter::printBlockPointerAfter(
const BlockPointerType *
T,
433 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
445void TypePrinter::printLValueReferenceBefore(
const LValueReferenceType *
T,
447 IncludeStrongLifetimeRAII Strong(Policy);
448 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
450 printBefore(Inner, OS);
458void TypePrinter::printLValueReferenceAfter(
const LValueReferenceType *
T,
460 IncludeStrongLifetimeRAII Strong(Policy);
461 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
467 printAfter(Inner, OS);
470void TypePrinter::printRValueReferenceBefore(
const RValueReferenceType *
T,
472 IncludeStrongLifetimeRAII Strong(Policy);
473 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
475 printBefore(Inner, OS);
483void TypePrinter::printRValueReferenceAfter(
const RValueReferenceType *
T,
485 IncludeStrongLifetimeRAII Strong(Policy);
486 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
492 printAfter(Inner, OS);
495void TypePrinter::printMemberPointerBefore(
const MemberPointerType *
T,
497 IncludeStrongLifetimeRAII Strong(Policy);
498 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
504 T->getQualifier().print(OS, Policy);
508void TypePrinter::printMemberPointerAfter(
const MemberPointerType *
T,
510 IncludeStrongLifetimeRAII Strong(Policy);
511 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
519void TypePrinter::printConstantArrayBefore(
const ConstantArrayType *
T,
521 IncludeStrongLifetimeRAII Strong(Policy);
522 printBefore(
T->getElementType(), OS);
525void TypePrinter::printConstantArrayAfter(
const ConstantArrayType *
T,
528 if (
T->getIndexTypeQualifiers().hasQualifiers()) {
534 if (
T->getSizeModifier() == ArraySizeModifier::Static)
537 OS <<
T->getZExtSize() <<
']';
538 printAfter(
T->getElementType(), OS);
541void TypePrinter::printIncompleteArrayBefore(
const IncompleteArrayType *
T,
543 IncludeStrongLifetimeRAII Strong(Policy);
544 printBefore(
T->getElementType(), OS);
547void TypePrinter::printIncompleteArrayAfter(
const IncompleteArrayType *
T,
550 printAfter(
T->getElementType(), OS);
553void TypePrinter::printVariableArrayBefore(
const VariableArrayType *
T,
555 IncludeStrongLifetimeRAII Strong(Policy);
556 printBefore(
T->getElementType(), OS);
559void TypePrinter::printVariableArrayAfter(
const VariableArrayType *
T,
562 if (
T->getIndexTypeQualifiers().hasQualifiers()) {
567 if (
T->getSizeModifier() == ArraySizeModifier::Static)
569 else if (
T->getSizeModifier() == ArraySizeModifier::Star)
572 if (
T->getSizeExpr())
573 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
576 printAfter(
T->getElementType(), OS);
579void TypePrinter::printAdjustedBefore(
const AdjustedType *
T, raw_ostream &OS) {
582 printBefore(
T->getAdjustedType(), OS);
585void TypePrinter::printAdjustedAfter(
const AdjustedType *
T, raw_ostream &OS) {
586 printAfter(
T->getAdjustedType(), OS);
589void TypePrinter::printDecayedBefore(
const DecayedType *
T, raw_ostream &OS) {
591 printAdjustedBefore(
T, OS);
594void TypePrinter::printArrayParameterAfter(
const ArrayParameterType *
T,
596 printConstantArrayAfter(
T, OS);
599void TypePrinter::printArrayParameterBefore(
const ArrayParameterType *
T,
601 printConstantArrayBefore(
T, OS);
604void TypePrinter::printDecayedAfter(
const DecayedType *
T, raw_ostream &OS) {
605 printAdjustedAfter(
T, OS);
608void TypePrinter::printDependentSizedArrayBefore(
609 const DependentSizedArrayType *
T,
611 IncludeStrongLifetimeRAII Strong(Policy);
612 printBefore(
T->getElementType(), OS);
615void TypePrinter::printDependentSizedArrayAfter(
616 const DependentSizedArrayType *
T,
619 if (
T->getSizeExpr())
620 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
622 printAfter(
T->getElementType(), OS);
625void TypePrinter::printDependentAddressSpaceBefore(
626 const DependentAddressSpaceType *
T, raw_ostream &OS) {
630void TypePrinter::printDependentAddressSpaceAfter(
631 const DependentAddressSpaceType *
T, raw_ostream &OS) {
632 OS <<
" __attribute__((address_space(";
633 if (
T->getAddrSpaceExpr())
634 T->getAddrSpaceExpr()->printPretty(OS,
nullptr, Policy);
639void TypePrinter::printDependentSizedExtVectorBefore(
640 const DependentSizedExtVectorType *
T,
644 printBefore(
T->getElementType(), OS);
647void TypePrinter::printDependentSizedExtVectorAfter(
648 const DependentSizedExtVectorType *
T,
652 if (
T->getSizeExpr())
653 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
656 OS <<
" __attribute__((ext_vector_type(";
657 if (
T->getSizeExpr())
658 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
661 printAfter(
T->getElementType(), OS);
664void TypePrinter::printVectorBefore(
const VectorType *
T, raw_ostream &OS) {
665 switch (
T->getVectorKind()) {
666 case VectorKind::AltiVecPixel:
667 OS <<
"__vector __pixel ";
669 case VectorKind::AltiVecBool:
670 OS <<
"__vector __bool ";
671 printBefore(
T->getElementType(), OS);
673 case VectorKind::AltiVecVector:
675 printBefore(
T->getElementType(), OS);
677 case VectorKind::Neon:
678 OS <<
"__attribute__((neon_vector_type("
679 <<
T->getNumElements() <<
"))) ";
680 printBefore(
T->getElementType(), OS);
682 case VectorKind::NeonPoly:
683 OS <<
"__attribute__((neon_polyvector_type(" <<
684 T->getNumElements() <<
"))) ";
685 printBefore(
T->getElementType(), OS);
687 case VectorKind::Generic: {
690 OS <<
"__attribute__((__vector_size__("
691 <<
T->getNumElements()
693 print(
T->getElementType(), OS, StringRef());
695 printBefore(
T->getElementType(), OS);
698 case VectorKind::SveFixedLengthData:
699 case VectorKind::SveFixedLengthPredicate:
702 OS <<
"__attribute__((__arm_sve_vector_bits__(";
704 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
707 OS <<
T->getNumElements() * 8;
709 OS <<
T->getNumElements();
712 print(
T->getElementType(), OS, StringRef());
715 printBefore(
T->getElementType(), OS);
717 case VectorKind::RVVFixedLengthData:
718 case VectorKind::RVVFixedLengthMask:
719 case VectorKind::RVVFixedLengthMask_1:
720 case VectorKind::RVVFixedLengthMask_2:
721 case VectorKind::RVVFixedLengthMask_4:
724 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
726 OS <<
T->getNumElements();
729 print(
T->getElementType(), OS, StringRef());
732 printBefore(
T->getElementType(), OS);
737void TypePrinter::printVectorAfter(
const VectorType *
T, raw_ostream &OS) {
738 printAfter(
T->getElementType(), OS);
741void TypePrinter::printDependentVectorBefore(
742 const DependentVectorType *
T, raw_ostream &OS) {
743 switch (
T->getVectorKind()) {
744 case VectorKind::AltiVecPixel:
745 OS <<
"__vector __pixel ";
747 case VectorKind::AltiVecBool:
748 OS <<
"__vector __bool ";
749 printBefore(
T->getElementType(), OS);
751 case VectorKind::AltiVecVector:
753 printBefore(
T->getElementType(), OS);
755 case VectorKind::Neon:
756 OS <<
"__attribute__((neon_vector_type(";
757 if (
T->getSizeExpr())
758 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
760 printBefore(
T->getElementType(), OS);
762 case VectorKind::NeonPoly:
763 OS <<
"__attribute__((neon_polyvector_type(";
764 if (
T->getSizeExpr())
765 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
767 printBefore(
T->getElementType(), OS);
769 case VectorKind::Generic: {
772 OS <<
"__attribute__((__vector_size__(";
773 if (
T->getSizeExpr())
774 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
776 print(
T->getElementType(), OS, StringRef());
778 printBefore(
T->getElementType(), OS);
781 case VectorKind::SveFixedLengthData:
782 case VectorKind::SveFixedLengthPredicate:
785 OS <<
"__attribute__((__arm_sve_vector_bits__(";
786 if (
T->getSizeExpr()) {
787 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
788 if (
T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
793 print(
T->getElementType(), OS, StringRef());
798 printBefore(
T->getElementType(), OS);
800 case VectorKind::RVVFixedLengthData:
801 case VectorKind::RVVFixedLengthMask:
802 case VectorKind::RVVFixedLengthMask_1:
803 case VectorKind::RVVFixedLengthMask_2:
804 case VectorKind::RVVFixedLengthMask_4:
807 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
808 if (
T->getSizeExpr()) {
809 T->getSizeExpr()->printPretty(OS,
nullptr, Policy);
811 print(
T->getElementType(), OS, StringRef());
816 printBefore(
T->getElementType(), OS);
821void TypePrinter::printDependentVectorAfter(
822 const DependentVectorType *
T, raw_ostream &OS) {
823 printAfter(
T->getElementType(), OS);
826void TypePrinter::printExtVectorBefore(
const ExtVectorType *
T,
830 printBefore(
T->getElementType(), OS);
833void TypePrinter::printExtVectorAfter(
const ExtVectorType *
T, raw_ostream &OS) {
834 printAfter(
T->getElementType(), OS);
838 OS <<
T->getNumElements();
841 OS <<
" __attribute__((ext_vector_type(";
842 OS <<
T->getNumElements();
848 OS <<
T->getNumRows() <<
", " <<
T->getNumColumns();
854 TP.printBefore(
T->getElementType(), OS);
865 TP.printBefore(
T->getElementType(), OS);
866 OS <<
" __attribute__((matrix_type(";
871void TypePrinter::printConstantMatrixBefore(
const ConstantMatrixType *
T,
880void TypePrinter::printConstantMatrixAfter(
const ConstantMatrixType *
T,
886 printAfter(
T->getElementType(), OS);
889void TypePrinter::printDependentSizedMatrixBefore(
890 const DependentSizedMatrixType *
T, raw_ostream &OS) {
891 printBefore(
T->getElementType(), OS);
892 OS <<
" __attribute__((matrix_type(";
893 if (
T->getRowExpr()) {
894 T->getRowExpr()->printPretty(OS,
nullptr, Policy);
897 if (
T->getColumnExpr()) {
898 T->getColumnExpr()->printPretty(OS,
nullptr, Policy);
903void TypePrinter::printDependentSizedMatrixAfter(
904 const DependentSizedMatrixType *
T, raw_ostream &OS) {
905 printAfter(
T->getElementType(), OS);
925 OS <<
" __attribute__((nothrow))";
941 if (
T->hasTrailingReturn()) {
943 if (!HasEmptyPlaceHolder)
948 printBefore(
T->getReturnType(), OS);
949 if (!PrevPHIsEmpty.get())
957 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
959 return "swift_context";
961 return "swift_async_context";
963 return "swift_error_result";
965 return "swift_indirect_result";
971 llvm_unreachable(
"bad parameter ABI kind");
977 if (!HasEmptyPlaceHolder)
983 ParamPolicyRAII ParamPolicy(Policy);
984 for (
unsigned i = 0, e =
T->getNumParams(); i != e; ++i) {
987 auto EPI =
T->getExtParameterInfo(i);
988 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
989 if (EPI.isNoEscape())
990 OS <<
"__attribute__((noescape)) ";
991 auto ABI = EPI.getABI();
999 print(
T->getParamType(i).getNonReferenceType(), OS, StringRef());
1002 }
else if (ABI != ParameterABI::Ordinary)
1024 OS <<
" __arm_streaming_compatible";
1026 OS <<
" __arm_streaming";
1028 OS <<
"__arm_agnostic(\"sme_za_state\")";
1030 OS <<
" __arm_preserves(\"za\")";
1032 OS <<
" __arm_in(\"za\")";
1034 OS <<
" __arm_out(\"za\")";
1036 OS <<
" __arm_inout(\"za\")";
1038 OS <<
" __arm_preserves(\"zt0\")";
1040 OS <<
" __arm_in(\"zt0\")";
1042 OS <<
" __arm_out(\"zt0\")";
1044 OS <<
" __arm_inout(\"zt0\")";
1046 printFunctionAfter(Info, OS);
1066 for (
const auto &CFE : FX) {
1067 OS <<
" __attribute__((" << CFE.Effect.name();
1068 if (
const Expr *E = CFE.Cond.getCondition()) {
1070 E->printPretty(OS,
nullptr, Policy);
1077 OS <<
" __attribute__((cfi_unchecked_callee))";
1086void TypePrinter::printFunctionAfter(
const FunctionType::ExtInfo &Info,
1088 if (!InsideCCAttribute) {
1089 switch (Info.
getCC()) {
1100 OS <<
" __attribute__((stdcall))";
1103 OS <<
" __attribute__((fastcall))";
1106 OS <<
" __attribute__((thiscall))";
1109 OS <<
" __attribute__((vectorcall))";
1112 OS <<
" __attribute__((pascal))";
1115 OS <<
" __attribute__((pcs(\"aapcs\")))";
1118 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1121 OS <<
" __attribute__((aarch64_vector_pcs))";
1124 OS <<
" __attribute__((aarch64_sve_pcs))";
1127 OS <<
" __attribute__((device_kernel))";
1130 OS <<
" __attribute__((intel_ocl_bicc))";
1133 OS <<
" __attribute__((ms_abi))";
1136 OS <<
" __attribute__((sysv_abi))";
1139 OS <<
" __attribute__((regcall))";
1145 OS <<
" __attribute__((swiftcall))";
1148 OS <<
"__attribute__((swiftasynccall))";
1151 OS <<
" __attribute__((preserve_most))";
1154 OS <<
" __attribute__((preserve_all))";
1157 OS <<
" __attribute__((m68k_rtd))";
1160 OS <<
" __attribute__((preserve_none))";
1163 OS <<
"__attribute__((riscv_vector_cc))";
1165#define CC_VLS_CASE(ABI_VLEN) \
1166 case CC_RISCVVLSCall_##ABI_VLEN: \
1167 OS << "__attribute__((riscv_vls_cc" #ABI_VLEN "))"; \
1186 OS <<
" __attribute__((noreturn))";
1188 OS <<
" __attribute__((cmse_nonsecure_call))";
1190 OS <<
" __attribute__((ns_returns_retained))";
1192 OS <<
" __attribute__((regparm ("
1195 OS <<
" __attribute__((no_caller_saved_registers))";
1197 OS <<
" __attribute__((nocf_check))";
1200void TypePrinter::printFunctionNoProtoBefore(
const FunctionNoProtoType *
T,
1203 SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder,
false);
1205 if (!PrevPHIsEmpty.get())
1209void TypePrinter::printFunctionNoProtoAfter(
const FunctionNoProtoType *
T,
1212 if (!HasEmptyPlaceHolder)
1214 SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder,
false);
1221void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) {
1231 spaceBeforePlaceHolder(OS);
1234void TypePrinter::printUnresolvedUsingBefore(
const UnresolvedUsingType *
T,
1236 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1237 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1239 auto *D =
T->getDecl();
1243 T->getQualifier().print(OS, Policy);
1246 spaceBeforePlaceHolder(OS);
1249void TypePrinter::printUnresolvedUsingAfter(
const UnresolvedUsingType *
T,
1252void TypePrinter::printUsingBefore(
const UsingType *
T, raw_ostream &OS) {
1253 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1254 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1256 auto *D =
T->getDecl();
1260 T->getQualifier().print(OS, Policy);
1263 spaceBeforePlaceHolder(OS);
1266void TypePrinter::printUsingAfter(
const UsingType *
T, raw_ostream &OS) {}
1268void TypePrinter::printTypedefBefore(
const TypedefType *
T, raw_ostream &OS) {
1269 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1270 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1272 auto *D =
T->getDecl();
1276 T->getQualifier().print(OS, Policy);
1279 spaceBeforePlaceHolder(OS);
1282void TypePrinter::printMacroQualifiedBefore(
const MacroQualifiedType *
T,
1284 StringRef MacroName =
T->getMacroIdentifier()->getName();
1285 OS << MacroName <<
" ";
1289 printBefore(
T->getModifiedType(), OS);
1292void TypePrinter::printMacroQualifiedAfter(
const MacroQualifiedType *
T,
1294 printAfter(
T->getModifiedType(), OS);
1297void TypePrinter::printTypedefAfter(
const TypedefType *
T, raw_ostream &OS) {}
1299void TypePrinter::printTypeOfExprBefore(
const TypeOfExprType *
T,
1301 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual "
1303 if (
T->getUnderlyingExpr())
1304 T->getUnderlyingExpr()->printPretty(OS,
nullptr, Policy);
1305 spaceBeforePlaceHolder(OS);
1308void TypePrinter::printTypeOfExprAfter(
const TypeOfExprType *
T,
1311void TypePrinter::printTypeOfBefore(
const TypeOfType *
T, raw_ostream &OS) {
1312 OS << (
T->getKind() == TypeOfKind::Unqualified ?
"typeof_unqual("
1314 print(
T->getUnmodifiedType(), OS, StringRef());
1316 spaceBeforePlaceHolder(OS);
1319void TypePrinter::printTypeOfAfter(
const TypeOfType *
T, raw_ostream &OS) {}
1321void TypePrinter::printDecltypeBefore(
const DecltypeType *
T, raw_ostream &OS) {
1323 if (
const Expr *E =
T->getUnderlyingExpr()) {
1324 PrintingPolicy ExprPolicy = Policy;
1326 E->printPretty(OS,
nullptr, ExprPolicy);
1329 spaceBeforePlaceHolder(OS);
1332void TypePrinter::printPackIndexingBefore(
const PackIndexingType *
T,
1334 if (
T->hasSelectedType()) {
1335 OS <<
T->getSelectedType();
1337 OS <<
T->getPattern() <<
"...[";
1338 T->getIndexExpr()->printPretty(OS,
nullptr, Policy);
1341 spaceBeforePlaceHolder(OS);
1344void TypePrinter::printPackIndexingAfter(
const PackIndexingType *
T,
1347void TypePrinter::printDecltypeAfter(
const DecltypeType *
T, raw_ostream &OS) {}
1349void TypePrinter::printUnaryTransformBefore(
const UnaryTransformType *
T,
1351 IncludeStrongLifetimeRAII Strong(Policy);
1353 static llvm::DenseMap<int, const char *> Transformation = {{
1354#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1355 {UnaryTransformType::Enum, "__" #Trait},
1356#include "clang/Basic/TransformTypeTraits.def"
1358 OS << Transformation[
T->getUTTKind()] <<
'(';
1359 print(
T->getBaseType(), OS, StringRef());
1361 spaceBeforePlaceHolder(OS);
1364void TypePrinter::printUnaryTransformAfter(
const UnaryTransformType *
T,
1367void TypePrinter::printAutoBefore(
const AutoType *
T, raw_ostream &OS) {
1369 if (!
T->getDeducedType().isNull()) {
1370 printBefore(
T->getDeducedType(), OS);
1372 if (
T->isConstrained()) {
1375 T->getTypeConstraintConcept()->getDeclName().print(OS, Policy);
1376 auto Args =
T->getTypeConstraintArguments();
1378 printTemplateArgumentList(
1380 T->getTypeConstraintConcept()->getTemplateParameters());
1383 switch (
T->getKeyword()) {
1384 case AutoTypeKeyword::Auto:
OS <<
"auto";
break;
1385 case AutoTypeKeyword::DecltypeAuto:
OS <<
"decltype(auto)";
break;
1386 case AutoTypeKeyword::GNUAutoType:
OS <<
"__auto_type";
break;
1388 spaceBeforePlaceHolder(OS);
1392void TypePrinter::printAutoAfter(
const AutoType *
T, raw_ostream &OS) {
1394 if (!
T->getDeducedType().isNull())
1395 printAfter(
T->getDeducedType(), OS);
1398void TypePrinter::printDeducedTemplateSpecializationBefore(
1399 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1401 T->getKeyword() != ElaboratedTypeKeyword::None)
1411 ArrayRef<TemplateArgument> Args;
1412 TemplateDecl *DeducedTD =
nullptr;
1413 if (!
T->getDeducedType().isNull()) {
1414 if (
const auto *TST =
1415 dyn_cast<TemplateSpecializationType>(
T->getDeducedType())) {
1416 DeducedTD = TST->getTemplateName().getAsTemplateDecl(
1418 Args = TST->template_arguments();
1423 DeducedTD = CD->getSpecializedTemplate();
1424 Args = CD->getTemplateArgs().asArray();
1438 IncludeStrongLifetimeRAII Strong(Policy);
1439 Name.
print(OS, Policy);
1442 printTemplateArgumentList(OS, Args, Policy,
1446 spaceBeforePlaceHolder(OS);
1449void TypePrinter::printDeducedTemplateSpecializationAfter(
1450 const DeducedTemplateSpecializationType *
T, raw_ostream &OS) {
1452 if (!
T->getDeducedType().isNull())
1453 printAfter(
T->getDeducedType(), OS);
1456void TypePrinter::printAtomicBefore(
const AtomicType *
T, raw_ostream &OS) {
1457 IncludeStrongLifetimeRAII Strong(Policy);
1460 print(
T->getValueType(), OS, StringRef());
1462 spaceBeforePlaceHolder(OS);
1465void TypePrinter::printAtomicAfter(
const AtomicType *
T, raw_ostream &OS) {}
1467void TypePrinter::printPipeBefore(
const PipeType *
T, raw_ostream &OS) {
1468 IncludeStrongLifetimeRAII Strong(Policy);
1470 if (
T->isReadOnly())
1473 OS <<
"write_only ";
1475 print(
T->getElementType(), OS, StringRef());
1476 spaceBeforePlaceHolder(OS);
1479void TypePrinter::printPipeAfter(
const PipeType *
T, raw_ostream &OS) {}
1481void TypePrinter::printBitIntBefore(
const BitIntType *
T, raw_ostream &OS) {
1482 if (
T->isUnsigned())
1484 OS <<
"_BitInt(" <<
T->getNumBits() <<
")";
1485 spaceBeforePlaceHolder(OS);
1488void TypePrinter::printBitIntAfter(
const BitIntType *
T, raw_ostream &OS) {}
1490void TypePrinter::printDependentBitIntBefore(
const DependentBitIntType *
T,
1492 if (
T->isUnsigned())
1495 T->getNumBitsExpr()->printPretty(OS,
nullptr, Policy);
1497 spaceBeforePlaceHolder(OS);
1500void TypePrinter::printDependentBitIntAfter(
const DependentBitIntType *
T,
1503void TypePrinter::printPredefinedSugarBefore(
const PredefinedSugarType *
T,
1505 OS <<
T->getIdentifier()->getName();
1506 spaceBeforePlaceHolder(OS);
1509void TypePrinter::printPredefinedSugarAfter(
const PredefinedSugarType *
T,
1512void TypePrinter::printTagType(
const TagType *
T, raw_ostream &OS) {
1513 TagDecl *D =
T->getDecl();
1516 D->
print(OS, Policy, Indentation);
1517 spaceBeforePlaceHolder(OS);
1521 bool PrintedKindDecoration =
false;
1524 PrintedKindDecoration =
true;
1529 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1530 if (
T->getKeyword() != ElaboratedTypeKeyword::None) {
1531 PrintedKindDecoration =
true;
1537 T->getQualifier().print(OS, Policy);
1548 clang::PrintingPolicy
Copy(Policy);
1551 if (PrintedKindDecoration) {
1552 Copy.SuppressTagKeywordInAnonNames =
true;
1553 Copy.SuppressTagKeyword =
true;
1561 if (
auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1562 const TemplateParameterList *TParams =
1563 S->getSpecializedTemplate()->getTemplateParameters();
1564 const ASTTemplateArgumentListInfo *TArgAsWritten =
1565 S->getTemplateArgsAsWritten();
1566 IncludeStrongLifetimeRAII Strong(Policy);
1568 printTemplateArgumentList(OS, TArgAsWritten->
arguments(), Policy,
1571 printTemplateArgumentList(OS, S->getTemplateArgs().asArray(), Policy,
1575 spaceBeforePlaceHolder(OS);
1578void TypePrinter::printRecordBefore(
const RecordType *
T, raw_ostream &OS) {
1581 for (
const auto *PNA :
T->getDecl()
1582 ->getMostRecentDecl()
1583 ->specific_attrs<PreferredNameAttr>()) {
1588 QualType
T = PNA->getTypedefType();
1590 if (
auto *TT = dyn_cast<TypedefType>(
T))
1591 return printTypeSpec(TT->getDecl(), OS);
1592 if (
auto *TST = dyn_cast<TemplateSpecializationType>(
T))
1593 return printTemplateId(TST, OS,
true);
1599 printTagType(
T, OS);
1602void TypePrinter::printRecordAfter(
const RecordType *
T, raw_ostream &OS) {}
1604void TypePrinter::printEnumBefore(
const EnumType *
T, raw_ostream &OS) {
1605 printTagType(
T, OS);
1608void TypePrinter::printEnumAfter(
const EnumType *
T, raw_ostream &OS) {}
1610void TypePrinter::printInjectedClassNameBefore(
const InjectedClassNameType *
T,
1612 const ASTContext &Ctx =
T->getDecl()->getASTContext();
1613 IncludeStrongLifetimeRAII Strong(Policy);
1614 T->getTemplateName(Ctx).print(OS, Policy);
1616 auto *
Decl =
T->getDecl();
1619 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(Decl)) {
1620 printTemplateArgumentList(OS, RD->getTemplateArgsAsWritten()->arguments(),
1622 T->getTemplateDecl()->getTemplateParameters());
1624 ClassTemplateDecl *TD =
Decl->getDescribedClassTemplate();
1626 printTemplateArgumentList(
1628 T->getTemplateDecl()->getTemplateParameters());
1631 spaceBeforePlaceHolder(OS);
1634void TypePrinter::printInjectedClassNameAfter(
const InjectedClassNameType *
T,
1637void TypePrinter::printTemplateTypeParmBefore(
const TemplateTypeParmType *
T,
1639 TemplateTypeParmDecl *D =
T->getDecl();
1642 TC->print(OS, Policy);
1646 }
else if (IdentifierInfo *Id =
T->getIdentifier())
1650 OS <<
"type-parameter-" <<
T->getDepth() <<
'-' <<
T->getIndex();
1652 spaceBeforePlaceHolder(OS);
1655void TypePrinter::printTemplateTypeParmAfter(
const TemplateTypeParmType *
T,
1658void TypePrinter::printSubstTemplateTypeParmBefore(
1659 const SubstTemplateTypeParmType *
T,
1661 IncludeStrongLifetimeRAII Strong(Policy);
1662 printBefore(
T->getReplacementType(), OS);
1665void TypePrinter::printSubstTemplateTypeParmAfter(
1666 const SubstTemplateTypeParmType *
T,
1668 IncludeStrongLifetimeRAII Strong(Policy);
1669 printAfter(
T->getReplacementType(), OS);
1672void TypePrinter::printSubstBuiltinTemplatePackBefore(
1673 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {
1674 IncludeStrongLifetimeRAII Strong(Policy);
1678void TypePrinter::printSubstBuiltinTemplatePackAfter(
1679 const SubstBuiltinTemplatePackType *
T, raw_ostream &OS) {}
1681void TypePrinter::printSubstTemplateTypeParmPackBefore(
1682 const SubstTemplateTypeParmPackType *
T,
1684 IncludeStrongLifetimeRAII Strong(Policy);
1685 if (
const TemplateTypeParmDecl *D =
T->getReplacedParameter()) {
1688 TC->print(OS, Policy);
1698 spaceBeforePlaceHolder(OS);
1702void TypePrinter::printSubstTemplateTypeParmPackAfter(
1703 const SubstTemplateTypeParmPackType *
T,
1705 IncludeStrongLifetimeRAII Strong(Policy);
1708void TypePrinter::printTemplateId(
const TemplateSpecializationType *
T,
1709 raw_ostream &OS,
bool FullyQualify) {
1710 IncludeStrongLifetimeRAII Strong(Policy);
1713 K != ElaboratedTypeKeyword::None)
1714 OS << TypeWithKeyword::getKeywordName(K) <<
' ';
1717 T->getTemplateName().getAsTemplateDecl(
true);
1719 if (FullyQualify && TD) {
1725 T->getTemplateName().print(OS, Policy,
1727 ? TemplateName::Qualified::AsWritten
1728 : TemplateName::Qualified::None);
1731 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1733 printTemplateArgumentList(OS,
T->template_arguments(), Policy, TPL);
1734 spaceBeforePlaceHolder(OS);
1737void TypePrinter::printTemplateSpecializationBefore(
1738 const TemplateSpecializationType *
T,
1743void TypePrinter::printTemplateSpecializationAfter(
1744 const TemplateSpecializationType *
T,
1747void TypePrinter::printParenBefore(
const ParenType *
T, raw_ostream &OS) {
1749 printBefore(
T->getInnerType(), OS);
1752 printBefore(
T->getInnerType(), OS);
1755void TypePrinter::printParenAfter(
const ParenType *
T, raw_ostream &OS) {
1758 printAfter(
T->getInnerType(), OS);
1760 printAfter(
T->getInnerType(), OS);
1763void TypePrinter::printDependentNameBefore(
const DependentNameType *
T,
1765 OS << TypeWithKeyword::getKeywordName(
T->getKeyword());
1766 if (
T->getKeyword() != ElaboratedTypeKeyword::None)
1768 T->getQualifier().print(OS, Policy);
1769 OS <<
T->getIdentifier()->getName();
1770 spaceBeforePlaceHolder(OS);
1773void TypePrinter::printDependentNameAfter(
const DependentNameType *
T,
1776void TypePrinter::printPackExpansionBefore(
const PackExpansionType *
T,
1778 printBefore(
T->getPattern(), OS);
1781void TypePrinter::printPackExpansionAfter(
const PackExpansionType *
T,
1783 printAfter(
T->getPattern(), OS);
1791 if (
T->isCountInBytes() &&
T->isOrNull())
1792 OS <<
"__sized_by_or_null(";
1793 else if (
T->isCountInBytes())
1794 OS <<
"__sized_by(";
1795 else if (
T->isOrNull())
1796 OS <<
"__counted_by_or_null(";
1798 OS <<
"__counted_by(";
1799 if (
T->getCountExpr())
1800 T->getCountExpr()->printPretty(OS,
nullptr, Policy);
1804void TypePrinter::printCountAttributedBefore(
const CountAttributedType *
T,
1811void TypePrinter::printCountAttributedAfter(
const CountAttributedType *
T,
1818void TypePrinter::printAttributedBefore(
const AttributedType *
T,
1823 if (
T->getAttrKind() == attr::ObjCGC ||
1824 T->getAttrKind() == attr::ObjCOwnership)
1825 return printBefore(
T->getEquivalentType(), OS);
1827 if (
T->getAttrKind() == attr::ObjCKindOf)
1830 if (
T->getAttrKind() == attr::PreserveNone) {
1831 OS <<
"__attribute__((preserve_none)) ";
1832 spaceBeforePlaceHolder(OS);
1833 }
else if (
T->getAttrKind() == attr::PreserveMost) {
1834 OS <<
"__attribute__((preserve_most)) ";
1835 spaceBeforePlaceHolder(OS);
1836 }
else if (
T->getAttrKind() == attr::PreserveAll) {
1837 OS <<
"__attribute__((preserve_all)) ";
1838 spaceBeforePlaceHolder(OS);
1841 if (
T->getAttrKind() == attr::AddressSpace)
1842 printBefore(
T->getEquivalentType(), OS);
1844 printBefore(
T->getModifiedType(), OS);
1846 if (
T->isMSTypeSpec()) {
1847 switch (
T->getAttrKind()) {
1849 case attr::Ptr32:
OS <<
" __ptr32";
break;
1850 case attr::Ptr64:
OS <<
" __ptr64";
break;
1851 case attr::SPtr:
OS <<
" __sptr";
break;
1852 case attr::UPtr:
OS <<
" __uptr";
break;
1854 spaceBeforePlaceHolder(OS);
1857 if (
T->isWebAssemblyFuncrefSpec())
1861 if (
T->getImmediateNullability()) {
1862 if (
T->getAttrKind() == attr::TypeNonNull)
1864 else if (
T->getAttrKind() == attr::TypeNullable)
1866 else if (
T->getAttrKind() == attr::TypeNullUnspecified)
1867 OS <<
" _Null_unspecified";
1868 else if (
T->getAttrKind() == attr::TypeNullableResult)
1869 OS <<
" _Nullable_result";
1871 llvm_unreachable(
"unhandled nullability");
1872 spaceBeforePlaceHolder(OS);
1876void TypePrinter::printAttributedAfter(
const AttributedType *
T,
1881 if (
T->getAttrKind() == attr::ObjCGC ||
1882 T->getAttrKind() == attr::ObjCOwnership)
1883 return printAfter(
T->getEquivalentType(), OS);
1887 SaveAndRestore MaybeSuppressCC(InsideCCAttribute,
T->isCallingConv());
1889 printAfter(
T->getModifiedType(), OS);
1893 if (
T->getAttrKind() == attr::ObjCKindOf ||
T->isMSTypeSpec() ||
1894 T->getImmediateNullability() ||
T->isWebAssemblyFuncrefSpec())
1898 if (
T->getAttrKind() == attr::ObjCInertUnsafeUnretained)
1902 if (
T->getAttrKind() == attr::NSReturnsRetained &&
1903 !
T->getEquivalentType()->
castAs<FunctionType>()
1904 ->getExtInfo().getProducesResult())
1907 if (
T->getAttrKind() == attr::LifetimeBound) {
1908 OS <<
" [[clang::lifetimebound]]";
1911 if (
T->getAttrKind() == attr::LifetimeCaptureBy) {
1912 OS <<
" [[clang::lifetime_capture_by(";
1913 if (
auto *attr = dyn_cast_or_null<LifetimeCaptureByAttr>(
T->getAttr()))
1914 llvm::interleaveComma(
attr->getArgIdents(), OS,
1915 [&](
auto it) { OS << it->getName(); });
1923 if (
T->getAttrKind() == attr::AddressSpace)
1926 if (
T->getAttrKind() == attr::AnnotateType) {
1931 OS <<
" [[clang::annotate_type(...)]]";
1935 if (
T->getAttrKind() == attr::ArmStreaming) {
1936 OS <<
"__arm_streaming";
1939 if (
T->getAttrKind() == attr::ArmStreamingCompatible) {
1940 OS <<
"__arm_streaming_compatible";
1944 if (
T->getAttrKind() == attr::SwiftAttr) {
1945 if (
auto *swiftAttr = dyn_cast_or_null<SwiftAttrAttr>(
T->getAttr())) {
1946 OS <<
" __attribute__((swift_attr(\"" << swiftAttr->getAttribute()
1952 if (
T->getAttrKind() == attr::PreserveAll ||
1953 T->getAttrKind() == attr::PreserveMost ||
1954 T->getAttrKind() == attr::PreserveNone) {
1959 OS <<
" __attribute__((";
1960 switch (
T->getAttrKind()) {
1961#define TYPE_ATTR(NAME)
1962#define DECL_OR_TYPE_ATTR(NAME)
1963#define ATTR(NAME) case attr::NAME:
1964#include "clang/Basic/AttrList.inc"
1965 llvm_unreachable(
"non-type attribute attached to type");
1967 case attr::BTFTypeTag:
1968 llvm_unreachable(
"BTFTypeTag attribute handled separately");
1970 case attr::HLSLResourceClass:
1972 case attr::HLSLRawBuffer:
1973 case attr::HLSLContainedType:
1974 case attr::HLSLIsCounter:
1975 llvm_unreachable(
"HLSL resource type attributes handled separately");
1977 case attr::OpenCLPrivateAddressSpace:
1978 case attr::OpenCLGlobalAddressSpace:
1979 case attr::OpenCLGlobalDeviceAddressSpace:
1980 case attr::OpenCLGlobalHostAddressSpace:
1981 case attr::OpenCLLocalAddressSpace:
1982 case attr::OpenCLConstantAddressSpace:
1983 case attr::OpenCLGenericAddressSpace:
1984 case attr::HLSLGroupSharedAddressSpace:
1989 case attr::CountedBy:
1990 case attr::CountedByOrNull:
1992 case attr::SizedByOrNull:
1993 case attr::LifetimeBound:
1994 case attr::LifetimeCaptureBy:
1995 case attr::TypeNonNull:
1996 case attr::TypeNullable:
1997 case attr::TypeNullableResult:
1998 case attr::TypeNullUnspecified:
2000 case attr::ObjCInertUnsafeUnretained:
2001 case attr::ObjCKindOf:
2002 case attr::ObjCOwnership:
2007 case attr::PointerAuth:
2008 case attr::AddressSpace:
2009 case attr::CmseNSCall:
2010 case attr::AnnotateType:
2011 case attr::WebAssemblyFuncref:
2012 case attr::ArmAgnostic:
2013 case attr::ArmStreaming:
2014 case attr::ArmStreamingCompatible:
2017 case attr::ArmInOut:
2018 case attr::ArmPreserves:
2019 case attr::NonBlocking:
2020 case attr::NonAllocating:
2021 case attr::Blocking:
2022 case attr::Allocating:
2023 case attr::SwiftAttr:
2024 case attr::PreserveAll:
2025 case attr::PreserveMost:
2026 case attr::PreserveNone:
2027 llvm_unreachable(
"This attribute should have been handled already");
2029 case attr::NSReturnsRetained:
2030 OS <<
"ns_returns_retained";
2035 case attr::AnyX86NoCfCheck:
OS <<
"nocf_check";
break;
2036 case attr::CDecl:
OS <<
"cdecl";
break;
2037 case attr::FastCall:
OS <<
"fastcall";
break;
2038 case attr::StdCall:
OS <<
"stdcall";
break;
2039 case attr::ThisCall:
OS <<
"thiscall";
break;
2040 case attr::SwiftCall:
OS <<
"swiftcall";
break;
2041 case attr::SwiftAsyncCall:
OS <<
"swiftasynccall";
break;
2042 case attr::VectorCall:
OS <<
"vectorcall";
break;
2043 case attr::Pascal:
OS <<
"pascal";
break;
2044 case attr::MSABI:
OS <<
"ms_abi";
break;
2045 case attr::SysVABI:
OS <<
"sysv_abi";
break;
2046 case attr::RegCall:
OS <<
"regcall";
break;
2049 QualType t =
T->getEquivalentType();
2053 "\"aapcs\"" :
"\"aapcs-vfp\"");
2057 case attr::AArch64VectorPcs:
OS <<
"aarch64_vector_pcs";
break;
2058 case attr::AArch64SVEPcs:
OS <<
"aarch64_sve_pcs";
break;
2059 case attr::IntelOclBicc:
2060 OS <<
"inteloclbicc";
2065 case attr::RISCVVectorCC:
2066 OS <<
"riscv_vector_cc";
2068 case attr::RISCVVLSCC:
2069 OS <<
"riscv_vls_cc";
2074 case attr::CFIUncheckedCallee:
2075 OS <<
"cfi_unchecked_callee";
2077 case attr::AcquireHandle:
2078 OS <<
"acquire_handle";
2080 case attr::ArmMveStrictPolymorphism:
2081 OS <<
"__clang_arm_mve_strict_polymorphism";
2083 case attr::ExtVectorType:
2084 OS <<
"ext_vector_type";
2093void TypePrinter::printBTFTagAttributedBefore(
const BTFTagAttributedType *
T,
2095 printBefore(
T->getWrappedType(), OS);
2096 OS <<
" __attribute__((btf_type_tag(\"" <<
T->getAttr()->getBTFTypeTag() <<
"\")))";
2099void TypePrinter::printBTFTagAttributedAfter(
const BTFTagAttributedType *
T,
2101 printAfter(
T->getWrappedType(), OS);
2104void TypePrinter::printHLSLAttributedResourceBefore(
2105 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2106 printBefore(
T->getWrappedType(), OS);
2109void TypePrinter::printHLSLAttributedResourceAfter(
2110 const HLSLAttributedResourceType *
T, raw_ostream &OS) {
2111 printAfter(
T->getWrappedType(), OS);
2112 const HLSLAttributedResourceType::Attributes &Attrs =
T->getAttrs();
2113 OS <<
" [[hlsl::resource_class("
2114 << HLSLResourceClassAttr::ConvertResourceClassToStr(Attrs.ResourceClass)
2117 OS <<
" [[hlsl::is_rov]]";
2118 if (Attrs.RawBuffer)
2119 OS <<
" [[hlsl::raw_buffer]]";
2120 if (Attrs.IsCounter)
2121 OS <<
" [[hlsl::is_counter]]";
2123 QualType ContainedTy =
T->getContainedType();
2124 if (!ContainedTy.
isNull()) {
2125 OS <<
" [[hlsl::contained_type(";
2126 printBefore(ContainedTy, OS);
2127 printAfter(ContainedTy, OS);
2132void TypePrinter::printHLSLInlineSpirvBefore(
const HLSLInlineSpirvType *
T,
2134 OS <<
"__hlsl_spirv_type<" <<
T->getOpcode();
2136 OS <<
", " <<
T->getSize();
2137 OS <<
", " <<
T->getAlignment();
2139 for (
auto &Operand :
T->getOperands()) {
2140 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2144 case SpirvOperandKind::ConstantId: {
2145 QualType ConstantType =
Operand.getResultType();
2146 OS <<
"vk::integral_constant<";
2147 printBefore(ConstantType, OS);
2148 printAfter(ConstantType, OS);
2154 case SpirvOperandKind::Literal:
2155 OS <<
"vk::Literal<vk::integral_constant<uint, ";
2159 case SpirvOperandKind::TypeId: {
2161 printBefore(
Type, OS);
2162 printAfter(
Type, OS);
2166 llvm_unreachable(
"Invalid SpirvOperand kind!");
2174void TypePrinter::printHLSLInlineSpirvAfter(
const HLSLInlineSpirvType *
T,
2179void TypePrinter::printObjCInterfaceBefore(
const ObjCInterfaceType *
T,
2181 OS <<
T->getDecl()->getName();
2182 spaceBeforePlaceHolder(OS);
2185void TypePrinter::printObjCInterfaceAfter(
const ObjCInterfaceType *
T,
2188void TypePrinter::printObjCTypeParamBefore(
const ObjCTypeParamType *
T,
2190 OS <<
T->getDecl()->getName();
2191 if (!
T->qual_empty()) {
2192 bool isFirst =
true;
2194 for (
const auto *I :
T->quals()) {
2204 spaceBeforePlaceHolder(OS);
2207void TypePrinter::printObjCTypeParamAfter(
const ObjCTypeParamType *
T,
2210void TypePrinter::printObjCObjectBefore(
const ObjCObjectType *
T,
2212 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2213 !
T->isKindOfTypeAsWritten())
2214 return printBefore(
T->getBaseType(), OS);
2216 if (
T->isKindOfTypeAsWritten())
2219 print(
T->getBaseType(), OS, StringRef());
2221 if (
T->isSpecializedAsWritten()) {
2222 bool isFirst =
true;
2224 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
2230 print(typeArg, OS, StringRef());
2235 if (!
T->qual_empty()) {
2236 bool isFirst =
true;
2238 for (
const auto *I :
T->quals()) {
2248 spaceBeforePlaceHolder(OS);
2251void TypePrinter::printObjCObjectAfter(
const ObjCObjectType *
T,
2253 if (
T->qual_empty() &&
T->isUnspecializedAsWritten() &&
2254 !
T->isKindOfTypeAsWritten())
2255 return printAfter(
T->getBaseType(), OS);
2258void TypePrinter::printObjCObjectPointerBefore(
const ObjCObjectPointerType *
T,
2265 if (HasEmptyPlaceHolder)
2271void TypePrinter::printObjCObjectPointerAfter(
const ObjCObjectPointerType *
T,
2282 llvm::raw_ostream &OS,
bool IncludeType) {
2283 A.
print(PP, OS, IncludeType);
2296 TemplateArgument Pattern,
2297 ArrayRef<TemplateArgument> Args,
2306 if (
auto *TTPT = Pattern->
getAsCanonical<TemplateTypeParmType>()) {
2307 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2310 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2322 if (TQual != PatQual)
2327 QualType TPointee =
T->getPointeeType();
2339 if (
auto *TTST =
T->getAs<TemplateSpecializationType>()) {
2340 Template = TTST->getTemplateName();
2341 TemplateArgs = TTST->template_arguments();
2342 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2343 T->getAsCXXRecordDecl())) {
2345 TemplateArgs = CTSD->getTemplateArgs().asArray();
2353 if (TemplateArgs.size() != PTST->template_arguments().size())
2355 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2357 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2408 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2409 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2410 Args[NTTP->getIndex()].structurallyEquals(Arg);
2426 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2427 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2436bool clang::isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
2437 const NamedDecl *Param,
2438 ArrayRef<TemplateArgument> Args,
2444 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2445 return TTPD->hasDefaultArgument() &&
2447 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2448 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2449 return TTPD->hasDefaultArgument() &&
2451 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2452 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2453 return NTTPD->hasDefaultArgument() &&
2455 Ctx, Arg, NTTPD->getDefaultArgument().getArgument(), Args,
2461template <
typename TA>
2467 !Args.empty() && !IsPack && Args.size() <= TPL->
size()) {
2469 for (
const TA &A : Args)
2471 while (!Args.empty() &&
getArgument(Args.back()).getIsDefaulted())
2472 Args = Args.drop_back();
2479 bool NeedSpace =
false;
2480 bool FirstArg =
true;
2481 for (
const auto &Arg : Args) {
2484 llvm::raw_svector_ostream ArgOS(Buf);
2497 Policy, TPL, ParmIndex));
2499 StringRef ArgString = ArgOS.str();
2504 if (FirstArg && ArgString.starts_with(
":"))
2511 if (!ArgString.empty()) {
2528void clang::printTemplateArgumentList(raw_ostream &OS,
2529 const TemplateArgumentListInfo &Args,
2530 const PrintingPolicy &Policy,
2531 const TemplateParameterList *TPL) {
2532 printTemplateArgumentList(OS, Args.
arguments(), Policy, TPL);
2535void clang::printTemplateArgumentList(raw_ostream &OS,
2536 ArrayRef<TemplateArgument> Args,
2537 const PrintingPolicy &Policy,
2538 const TemplateParameterList *TPL) {
2539 PrintingPolicy InnerPolicy = Policy;
2541 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2544void clang::printTemplateArgumentList(raw_ostream &OS,
2545 ArrayRef<TemplateArgumentLoc> Args,
2546 const PrintingPolicy &Policy,
2547 const TemplateParameterList *TPL) {
2548 PrintingPolicy InnerPolicy = Policy;
2550 printTo(OS, Args, InnerPolicy, TPL,
false, 0);
2560 llvm::raw_svector_ostream StrOS(Buf);
2562 return StrOS.str().str();
2590 llvm::raw_svector_ostream StrOS(Buf);
2591 print(StrOS, Policy);
2592 return std::string(StrOS.str());
2610 PointerAuth && !PointerAuth.isEmptyWhenPrinted(Policy))
2630 return "__constant";
2635 return "__global_device";
2638 return "__global_host";
2640 return "__device__";
2642 return "__constant__";
2644 return "__shared__";
2646 return "__sptr __ptr32";
2648 return "__uptr __ptr32";
2652 return "groupshared";
2654 return "hlsl_constant";
2656 return "hlsl_private";
2658 return "hlsl_device";
2660 return "hlsl_input";
2662 return "hlsl_push_constant";
2674 bool appendSpaceIfNonEmpty)
const {
2675 bool addSpace =
false;
2685 OS <<
"__unaligned";
2689 if (!ASStr.empty()) {
2695 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2734 PointerAuth.print(OS, Policy);
2737 if (appendSpaceIfNonEmpty && addSpace)
2759 const Twine &PlaceHolder,
unsigned Indentation)
const {
2766 const Twine &PlaceHolder,
unsigned Indentation) {
2768 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2770 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2780 std::string &buffer,
2783 llvm::raw_svector_ostream StrOS(Buf);
2784 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2785 std::string str = std::string(StrOS.str());
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the clang::attr::Kind enum.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx, QualType Ty)
#define CC_VLS_CASE(ABI_VLEN)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static void printHLSLMatrixBefore(TypePrinter &TP, const ConstantMatrixType *T, raw_ostream &OS)
static void printTo(raw_ostream &OS, ArrayRef< TA > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex)
static const TemplateArgument & getArgument(const TemplateArgument &A)
static bool isSubstitutedType(ASTContext &Ctx, QualType T, QualType Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP, llvm::raw_ostream &OS, bool IncludeType)
static QualType skipTopLevelReferences(QualType T)
static void printClangMatrixBefore(TypePrinter &TP, const ConstantMatrixType *T, raw_ostream &OS)
static void printDims(const ConstantMatrixType *T, raw_ostream &OS)
static void printHLSLMatrixAfter(const ConstantMatrixType *T, raw_ostream &OS)
static void printCountAttributedImpl(const CountAttributedType *T, raw_ostream &OS, const PrintingPolicy &Policy)
static SplitQualType splitAccordingToPolicy(QualType QT, const PrintingPolicy &Policy)
static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg, TemplateArgument Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, bool HasRestrictKeyword)
static bool templateArgumentExpressionsEqual(ASTContext const &Ctx, TemplateArgument const &Pattern, TemplateArgument const &Arg)
Evaluates the expression template argument 'Pattern' and returns true if 'Arg' evaluates to the same ...
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
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.
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)
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 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 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 SuppressScope
Suppresses printing of scope specifiers.
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.