35#include "llvm/ADT/ArrayRef.h"
36#include "llvm/ADT/DenseMap.h"
37#include "llvm/ADT/SmallString.h"
38#include "llvm/ADT/StringRef.h"
39#include "llvm/ADT/Twine.h"
40#include "llvm/Support/Casting.h"
41#include "llvm/Support/Compiler.h"
42#include "llvm/Support/ErrorHandling.h"
43#include "llvm/Support/SaveAndRestore.h"
44#include "llvm/Support/raw_ostream.h"
54class IncludeStrongLifetimeRAII {
60 : Policy(Policy), Old(Policy.SuppressStrongLifetime) {
68class ParamPolicyRAII {
74 : Policy(Policy), Old(Policy.SuppressSpecifiers) {
81class DefaultTemplateArgsPolicyRAII {
87 : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) {
94class ElaboratedTypePolicyRAII {
96 bool SuppressTagKeyword;
100 explicit ElaboratedTypePolicyRAII(
PrintingPolicy &Policy) : Policy(Policy) {
107 ~ElaboratedTypePolicyRAII() {
115 unsigned Indentation;
116 bool HasEmptyPlaceHolder =
false;
117 bool InsideCCAttribute =
false;
120 explicit TypePrinter(
const PrintingPolicy &Policy,
unsigned Indentation = 0)
121 : Policy(Policy), Indentation(Indentation) {}
124 StringRef PlaceHolder);
125 void print(
QualType T, raw_ostream &OS, StringRef PlaceHolder);
127 static bool canPrefixQualifiers(
const Type *T,
bool &NeedARCStrongQualifier);
128 void spaceBeforePlaceHolder(raw_ostream &OS);
129 void printTypeSpec(
NamedDecl *D, raw_ostream &OS);
133 void printBefore(
QualType T, raw_ostream &OS);
134 void printAfter(
QualType T, raw_ostream &OS);
137 void printTag(
TagDecl *T, raw_ostream &OS);
139#define ABSTRACT_TYPE(CLASS, PARENT)
140#define TYPE(CLASS, PARENT) \
141 void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
142 void print##CLASS##After(const CLASS##Type *T, raw_ostream &OS);
143#include "clang/AST/TypeNodes.inc"
153 bool HasRestrictKeyword) {
154 bool appendSpace =
false;
160 if (appendSpace) OS <<
' ';
165 if (appendSpace) OS <<
' ';
166 if (HasRestrictKeyword) {
174void TypePrinter::spaceBeforePlaceHolder(raw_ostream &OS) {
175 if (!HasEmptyPlaceHolder)
186void TypePrinter::print(
QualType t, raw_ostream &OS, StringRef PlaceHolder) {
191void TypePrinter::print(
const Type *T,
Qualifiers Quals, raw_ostream &OS,
192 StringRef PlaceHolder) {
200 printBefore(T, Quals, OS);
202 printAfter(T, Quals, OS);
205bool TypePrinter::canPrefixQualifiers(
const Type *T,
206 bool &NeedARCStrongQualifier) {
212 bool CanPrefixQualifiers =
false;
213 NeedARCStrongQualifier =
false;
214 const Type *UnderlyingType = T;
215 if (
const auto *AT = dyn_cast<AutoType>(T))
216 UnderlyingType = AT->desugar().getTypePtr();
217 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T))
218 UnderlyingType = Subst->getReplacementType().getTypePtr();
225 case Type::UnresolvedUsing:
228 case Type::TypeOfExpr:
231 case Type::UnaryTransform:
234 case Type::Elaborated:
235 case Type::TemplateTypeParm:
236 case Type::SubstTemplateTypeParmPack:
237 case Type::DeducedTemplateSpecialization:
238 case Type::TemplateSpecialization:
239 case Type::InjectedClassName:
240 case Type::DependentName:
241 case Type::DependentTemplateSpecialization:
242 case Type::ObjCObject:
243 case Type::ObjCTypeParam:
244 case Type::ObjCInterface:
248 case Type::DependentBitInt:
249 case Type::BTFTagAttributed:
250 CanPrefixQualifiers =
true;
253 case Type::ObjCObjectPointer:
258 case Type::VariableArray:
259 case Type::DependentSizedArray:
260 NeedARCStrongQualifier =
true;
263 case Type::ConstantArray:
264 case Type::IncompleteArray:
265 return canPrefixQualifiers(
266 cast<ArrayType>(UnderlyingType)->getElementType().getTypePtr(),
267 NeedARCStrongQualifier);
272 case Type::BlockPointer:
273 case Type::LValueReference:
274 case Type::RValueReference:
275 case Type::MemberPointer:
276 case Type::DependentAddressSpace:
277 case Type::DependentVector:
278 case Type::DependentSizedExtVector:
280 case Type::ExtVector:
281 case Type::ConstantMatrix:
282 case Type::DependentSizedMatrix:
283 case Type::FunctionProto:
284 case Type::FunctionNoProto:
286 case Type::PackExpansion:
287 case Type::SubstTemplateTypeParm:
288 case Type::MacroQualified:
289 CanPrefixQualifiers =
false;
292 case Type::Attributed: {
295 const auto *AttrTy = cast<AttributedType>(UnderlyingType);
296 CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace;
301 return CanPrefixQualifiers;
304void TypePrinter::printBefore(
QualType T, raw_ostream &OS) {
310 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
Split.Ty))
313 printBefore(
Split.Ty, Quals, OS);
318void TypePrinter::printBefore(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
326 bool CanPrefixQualifiers =
false;
327 bool NeedARCStrongQualifier =
false;
328 CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
330 if (CanPrefixQualifiers && !Quals.
empty()) {
331 if (NeedARCStrongQualifier) {
332 IncludeStrongLifetimeRAII Strong(Policy);
333 Quals.
print(OS, Policy,
true);
335 Quals.
print(OS, Policy,
true);
339 bool hasAfterQuals =
false;
340 if (!CanPrefixQualifiers && !Quals.
empty()) {
343 HasEmptyPlaceHolder =
false;
347#define ABSTRACT_TYPE(CLASS, PARENT)
348#define TYPE(CLASS, PARENT) case Type::CLASS: \
349 print##CLASS##Before(cast<CLASS##Type>(T), OS); \
351#include "clang/AST/TypeNodes.inc"
355 if (NeedARCStrongQualifier) {
356 IncludeStrongLifetimeRAII Strong(Policy);
357 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
359 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
364void TypePrinter::printAfter(
QualType t, raw_ostream &OS) {
366 printAfter(split.
Ty, split.
Quals, OS);
371void TypePrinter::printAfter(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
373#define ABSTRACT_TYPE(CLASS, PARENT)
374#define TYPE(CLASS, PARENT) case Type::CLASS: \
375 print##CLASS##After(cast<CLASS##Type>(T), OS); \
377#include "clang/AST/TypeNodes.inc"
381void TypePrinter::printBuiltinBefore(
const BuiltinType *T, raw_ostream &OS) {
383 spaceBeforePlaceHolder(OS);
386void TypePrinter::printBuiltinAfter(
const BuiltinType *T, raw_ostream &OS) {}
388void TypePrinter::printComplexBefore(
const ComplexType *T, raw_ostream &OS) {
393void TypePrinter::printComplexAfter(
const ComplexType *T, raw_ostream &OS) {
397void TypePrinter::printPointerBefore(
const PointerType *T, raw_ostream &OS) {
398 IncludeStrongLifetimeRAII Strong(Policy);
408void TypePrinter::printPointerAfter(
const PointerType *T, raw_ostream &OS) {
409 IncludeStrongLifetimeRAII Strong(Policy);
441 IncludeStrongLifetimeRAII Strong(Policy);
444 printBefore(Inner, OS);
447 if (isa<ArrayType>(Inner))
454 IncludeStrongLifetimeRAII Strong(Policy);
459 if (isa<ArrayType>(Inner))
461 printAfter(Inner, OS);
466 IncludeStrongLifetimeRAII Strong(Policy);
469 printBefore(Inner, OS);
472 if (isa<ArrayType>(Inner))
479 IncludeStrongLifetimeRAII Strong(Policy);
484 if (isa<ArrayType>(Inner))
486 printAfter(Inner, OS);
491 IncludeStrongLifetimeRAII Strong(Policy);
500 InnerPolicy.IncludeTagDefinition =
false;
501 TypePrinter(InnerPolicy).print(
QualType(T->
getClass(), 0), OS, StringRef());
508 IncludeStrongLifetimeRAII Strong(Policy);
519 IncludeStrongLifetimeRAII Strong(Policy);
535 OS << T->
getSize().getZExtValue() <<
']';
541 IncludeStrongLifetimeRAII Strong(Policy);
553 IncludeStrongLifetimeRAII Strong(Policy);
577void TypePrinter::printAdjustedBefore(
const AdjustedType *T, raw_ostream &OS) {
583void TypePrinter::printAdjustedAfter(
const AdjustedType *T, raw_ostream &OS) {
587void TypePrinter::printDecayedBefore(
const DecayedType *T, raw_ostream &OS) {
589 printAdjustedBefore(T, OS);
592void TypePrinter::printDecayedAfter(
const DecayedType *T, raw_ostream &OS) {
593 printAdjustedAfter(T, OS);
596void TypePrinter::printDependentSizedArrayBefore(
599 IncludeStrongLifetimeRAII Strong(Policy);
603void TypePrinter::printDependentSizedArrayAfter(
613void TypePrinter::printDependentAddressSpaceBefore(
618void TypePrinter::printDependentAddressSpaceAfter(
620 OS <<
" __attribute__((address_space(";
627void TypePrinter::printDependentSizedExtVectorBefore(
633void TypePrinter::printDependentSizedExtVectorAfter(
636 OS <<
" __attribute__((ext_vector_type(";
643void TypePrinter::printVectorBefore(
const VectorType *T, raw_ostream &OS) {
645 case VectorKind::AltiVecPixel:
646 OS <<
"__vector __pixel ";
648 case VectorKind::AltiVecBool:
649 OS <<
"__vector __bool ";
652 case VectorKind::AltiVecVector:
656 case VectorKind::Neon:
657 OS <<
"__attribute__((neon_vector_type("
661 case VectorKind::NeonPoly:
662 OS <<
"__attribute__((neon_polyvector_type(" <<
666 case VectorKind::Generic: {
669 OS <<
"__attribute__((__vector_size__("
677 case VectorKind::SveFixedLengthData:
678 case VectorKind::SveFixedLengthPredicate:
681 OS <<
"__attribute__((__arm_sve_vector_bits__(";
683 if (T->
getVectorKind() == VectorKind::SveFixedLengthPredicate)
696 case VectorKind::RVVFixedLengthData:
699 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
712void TypePrinter::printVectorAfter(
const VectorType *T, raw_ostream &OS) {
716void TypePrinter::printDependentVectorBefore(
719 case VectorKind::AltiVecPixel:
720 OS <<
"__vector __pixel ";
722 case VectorKind::AltiVecBool:
723 OS <<
"__vector __bool ";
726 case VectorKind::AltiVecVector:
730 case VectorKind::Neon:
731 OS <<
"__attribute__((neon_vector_type(";
737 case VectorKind::NeonPoly:
738 OS <<
"__attribute__((neon_polyvector_type(";
744 case VectorKind::Generic: {
747 OS <<
"__attribute__((__vector_size__(";
756 case VectorKind::SveFixedLengthData:
757 case VectorKind::SveFixedLengthPredicate:
760 OS <<
"__attribute__((__arm_sve_vector_bits__(";
763 if (T->
getVectorKind() == VectorKind::SveFixedLengthPredicate)
775 case VectorKind::RVVFixedLengthData:
778 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
792void TypePrinter::printDependentVectorAfter(
797void TypePrinter::printExtVectorBefore(
const ExtVectorType *T,
802void TypePrinter::printExtVectorAfter(
const ExtVectorType *T, raw_ostream &OS) {
804 OS <<
" __attribute__((ext_vector_type(";
812 OS <<
" __attribute__((matrix_type(";
822void TypePrinter::printDependentSizedMatrixBefore(
825 OS <<
" __attribute__((matrix_type(";
836void TypePrinter::printDependentSizedMatrixAfter(
858 OS <<
" __attribute__((nothrow))";
876 if (!HasEmptyPlaceHolder)
882 if (!PrevPHIsEmpty.get())
890 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
892 return "swift_context";
894 return "swift_async_context";
896 return "swift_error_result";
898 return "swift_indirect_result";
900 llvm_unreachable(
"bad parameter ABI kind");
906 if (!HasEmptyPlaceHolder)
912 ParamPolicyRAII ParamPolicy(Policy);
913 for (
unsigned i = 0, e = T->
getNumParams(); i != e; ++i) {
917 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
918 if (EPI.isNoEscape())
919 OS <<
"__attribute__((noescape)) ";
920 auto ABI = EPI.getABI();
932 }
else if (T->
getNumParams() == 0 && Policy.UseVoidForZeroParams) {
942 OS <<
" __arm_streaming_compatible";
944 OS <<
" __arm_streaming";
946 OS <<
" __arm_shared_za";
948 OS <<
" __arm_preserves_za";
950 printFunctionAfter(Info, OS);
978 if (!InsideCCAttribute) {
979 switch (Info.
getCC()) {
990 OS <<
" __attribute__((stdcall))";
993 OS <<
" __attribute__((fastcall))";
996 OS <<
" __attribute__((thiscall))";
999 OS <<
" __attribute__((vectorcall))";
1002 OS <<
" __attribute__((pascal))";
1005 OS <<
" __attribute__((pcs(\"aapcs\")))";
1008 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1011 OS <<
"__attribute__((aarch64_vector_pcs))";
1014 OS <<
"__attribute__((aarch64_sve_pcs))";
1017 OS <<
"__attribute__((amdgpu_kernel))";
1020 OS <<
" __attribute__((intel_ocl_bicc))";
1023 OS <<
" __attribute__((ms_abi))";
1026 OS <<
" __attribute__((sysv_abi))";
1029 OS <<
" __attribute__((regcall))";
1036 OS <<
" __attribute__((swiftcall))";
1039 OS <<
"__attribute__((swiftasynccall))";
1042 OS <<
" __attribute__((preserve_most))";
1045 OS <<
" __attribute__((preserve_all))";
1048 OS <<
" __attribute__((m68k_rtd))";
1054 OS <<
" __attribute__((noreturn))";
1056 OS <<
" __attribute__((cmse_nonsecure_call))";
1058 OS <<
" __attribute__((ns_returns_retained))";
1060 OS <<
" __attribute__((regparm ("
1063 OS <<
" __attribute__((no_caller_saved_registers))";
1065 OS <<
" __attribute__((nocf_check))";
1073 if (!PrevPHIsEmpty.get())
1080 if (!HasEmptyPlaceHolder)
1089void TypePrinter::printTypeSpec(
NamedDecl *D, raw_ostream &OS) {
1094 if (!Policy.SuppressScope)
1099 spaceBeforePlaceHolder(OS);
1104 printTypeSpec(T->
getDecl(), OS);
1110void TypePrinter::printUsingBefore(
const UsingType *T, raw_ostream &OS) {
1123void TypePrinter::printUsingAfter(
const UsingType *T, raw_ostream &OS) {}
1125void TypePrinter::printTypedefBefore(
const TypedefType *T, raw_ostream &OS) {
1126 printTypeSpec(T->
getDecl(), OS);
1132 OS << MacroName <<
" ";
1144void TypePrinter::printTypedefAfter(
const TypedefType *T, raw_ostream &OS) {}
1152 spaceBeforePlaceHolder(OS);
1158void TypePrinter::printTypeOfBefore(
const TypeOfType *T, raw_ostream &OS) {
1163 spaceBeforePlaceHolder(OS);
1166void TypePrinter::printTypeOfAfter(
const TypeOfType *T, raw_ostream &OS) {}
1168void TypePrinter::printDecltypeBefore(
const DecltypeType *T, raw_ostream &OS) {
1173 spaceBeforePlaceHolder(OS);
1176void TypePrinter::printDecltypeAfter(
const DecltypeType *T, raw_ostream &OS) {}
1180 IncludeStrongLifetimeRAII Strong(Policy);
1182 static llvm::DenseMap<int, const char *> Transformation = {{
1183#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1184 {UnaryTransformType::Enum, "__" #Trait},
1185#include "clang/Basic/TransformTypeTraits.def"
1187 OS << Transformation[T->
getUTTKind()] <<
'(';
1190 spaceBeforePlaceHolder(OS);
1196void TypePrinter::printAutoBefore(
const AutoType *T, raw_ostream &OS) {
1217 spaceBeforePlaceHolder(OS);
1221void TypePrinter::printAutoAfter(
const AutoType *T, raw_ostream &OS) {
1227void TypePrinter::printDeducedTemplateSpecializationBefore(
1233 IncludeStrongLifetimeRAII Strong(Policy);
1235 spaceBeforePlaceHolder(OS);
1239void TypePrinter::printDeducedTemplateSpecializationAfter(
1246void TypePrinter::printAtomicBefore(
const AtomicType *T, raw_ostream &OS) {
1247 IncludeStrongLifetimeRAII Strong(Policy);
1252 spaceBeforePlaceHolder(OS);
1255void TypePrinter::printAtomicAfter(
const AtomicType *T, raw_ostream &OS) {}
1257void TypePrinter::printPipeBefore(
const PipeType *T, raw_ostream &OS) {
1258 IncludeStrongLifetimeRAII Strong(Policy);
1263 OS <<
"write_only ";
1266 spaceBeforePlaceHolder(OS);
1269void TypePrinter::printPipeAfter(
const PipeType *T, raw_ostream &OS) {}
1271void TypePrinter::printBitIntBefore(
const BitIntType *T, raw_ostream &OS) {
1275 spaceBeforePlaceHolder(OS);
1278void TypePrinter::printBitIntAfter(
const BitIntType *T, raw_ostream &OS) {}
1287 spaceBeforePlaceHolder(OS);
1294void TypePrinter::AppendScope(
DeclContext *DC, raw_ostream &OS,
1304 if (Policy.Callbacks && Policy.Callbacks->isScopeVisible(DC))
1307 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1308 if (Policy.SuppressUnwrittenScope && NS->isAnonymousNamespace())
1309 return AppendScope(DC->
getParent(), OS, NameInScope);
1313 if (Policy.SuppressInlineNamespace && NS->isInline() && NameInScope &&
1314 NS->isRedundantInlineQualifierFor(NameInScope))
1315 return AppendScope(DC->
getParent(), OS, NameInScope);
1317 AppendScope(DC->
getParent(), OS, NS->getDeclName());
1318 if (NS->getIdentifier())
1319 OS << NS->getName() <<
"::";
1321 OS <<
"(anonymous namespace)::";
1322 }
else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1323 AppendScope(DC->
getParent(), OS, Spec->getDeclName());
1324 IncludeStrongLifetimeRAII Strong(Policy);
1325 OS << Spec->getIdentifier()->getName();
1328 OS, TemplateArgs.
asArray(), Policy,
1329 Spec->getSpecializedTemplate()->getTemplateParameters());
1331 }
else if (
const auto *Tag = dyn_cast<TagDecl>(DC)) {
1332 AppendScope(DC->
getParent(), OS, Tag->getDeclName());
1334 OS << Typedef->getIdentifier()->getName() <<
"::";
1335 else if (Tag->getIdentifier())
1336 OS << Tag->getIdentifier()->getName() <<
"::";
1340 AppendScope(DC->
getParent(), OS, NameInScope);
1344void TypePrinter::printTag(
TagDecl *D, raw_ostream &OS) {
1345 if (Policy.IncludeTagDefinition) {
1348 D->
print(OS, SubPolicy, Indentation);
1349 spaceBeforePlaceHolder(OS);
1353 bool HasKindDecoration =
false;
1358 HasKindDecoration =
true;
1366 if (!Policy.SuppressScope)
1372 assert(Typedef->getIdentifier() &&
"Typedef without identifier?");
1373 OS << Typedef->getIdentifier()->getName();
1377 OS << (Policy.MSVCFormatting ?
'`' :
'(');
1379 if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) {
1381 HasKindDecoration =
true;
1382 }
else if ((isa<RecordDecl>(D) && cast<RecordDecl>(D)->isAnonymousStructOrUnion())) {
1388 if (Policy.AnonymousTagLocations) {
1392 if (!HasKindDecoration)
1401 if (
auto *Callbacks = Policy.Callbacks)
1402 WrittenFile = Callbacks->remapPath(
File);
1406 llvm::sys::path::Style Style =
1407 llvm::sys::path::is_absolute(WrittenFile)
1408 ? llvm::sys::path::Style::native
1409 : (Policy.MSVCFormatting
1410 ? llvm::sys::path::Style::windows_backslash
1411 : llvm::sys::path::Style::posix);
1412 llvm::sys::path::native(WrittenFile, Style);
1417 OS << (Policy.MSVCFormatting ?
'\'' :
')');
1422 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1425 if (!Policy.PrintCanonicalTypes && TAW) {
1427 cast<TemplateSpecializationType>(TAW->
getType());
1431 Args = TemplateArgs.
asArray();
1433 IncludeStrongLifetimeRAII Strong(Policy);
1436 Spec->getSpecializedTemplate()->getTemplateParameters());
1439 spaceBeforePlaceHolder(OS);
1442void TypePrinter::printRecordBefore(
const RecordType *T, raw_ostream &OS) {
1444 if (Policy.UsePreferredNames) {
1450 QualType T = PNA->getTypedefType();
1452 if (
auto *TT = dyn_cast<TypedefType>(T))
1453 return printTypeSpec(TT->getDecl(), OS);
1454 if (
auto *TST = dyn_cast<TemplateSpecializationType>(T))
1455 return printTemplateId(TST, OS,
true);
1461 printTag(T->getDecl(), OS);
1464void TypePrinter::printRecordAfter(
const RecordType *T, raw_ostream &OS) {}
1466void TypePrinter::printEnumBefore(
const EnumType *T, raw_ostream &OS) {
1470void TypePrinter::printEnumAfter(
const EnumType *T, raw_ostream &OS) {}
1477 TC->
print(OS, Policy);
1482 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1487 spaceBeforePlaceHolder(OS);
1493void TypePrinter::printSubstTemplateTypeParmBefore(
1496 IncludeStrongLifetimeRAII Strong(Policy);
1500void TypePrinter::printSubstTemplateTypeParmAfter(
1503 IncludeStrongLifetimeRAII Strong(Policy);
1507void TypePrinter::printSubstTemplateTypeParmPackBefore(
1510 IncludeStrongLifetimeRAII Strong(Policy);
1514 TC->print(OS, Policy);
1519 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1524 spaceBeforePlaceHolder(OS);
1528void TypePrinter::printSubstTemplateTypeParmPackAfter(
1531 IncludeStrongLifetimeRAII Strong(Policy);
1535 raw_ostream &OS,
bool FullyQualify) {
1536 IncludeStrongLifetimeRAII Strong(Policy);
1540 if (FullyQualify && TD) {
1541 if (!Policy.SuppressScope)
1549 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1552 spaceBeforePlaceHolder(OS);
1555void TypePrinter::printTemplateSpecializationBefore(
1558 printTemplateId(T, OS, Policy.FullyQualifiedName);
1561void TypePrinter::printTemplateSpecializationAfter(
1567 if (Policy.PrintInjectedClassNameWithArguments)
1568 return printTemplateSpecializationBefore(T->
getInjectedTST(), OS);
1570 IncludeStrongLifetimeRAII Strong(Policy);
1572 spaceBeforePlaceHolder(OS);
1583 "OwnedTagDecl expected to be a declaration for the type");
1586 OwnedTagDecl->
print(OS, SubPolicy, Indentation);
1587 spaceBeforePlaceHolder(OS);
1591 if (Policy.SuppressElaboration) {
1597 if (!Policy.IncludeTagDefinition)
1607 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1616 if (Policy.SuppressElaboration) {
1621 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1625void TypePrinter::printParenBefore(
const ParenType *T, raw_ostream &OS) {
1626 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1633void TypePrinter::printParenAfter(
const ParenType *T, raw_ostream &OS) {
1634 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1650 spaceBeforePlaceHolder(OS);
1656void TypePrinter::printDependentTemplateSpecializationBefore(
1658 IncludeStrongLifetimeRAII Strong(Policy);
1668 spaceBeforePlaceHolder(OS);
1671void TypePrinter::printDependentTemplateSpecializationAfter(
1705 case attr::Ptr32: OS <<
" __ptr32";
break;
1706 case attr::Ptr64: OS <<
" __ptr64";
break;
1707 case attr::SPtr: OS <<
" __sptr";
break;
1708 case attr::UPtr: OS <<
" __uptr";
break;
1710 spaceBeforePlaceHolder(OS);
1722 else if (T->
getAttrKind() == attr::TypeNullUnspecified)
1723 OS <<
" _Null_unspecified";
1724 else if (T->
getAttrKind() == attr::TypeNullableResult)
1725 OS <<
" _Nullable_result";
1727 llvm_unreachable(
"unhandled nullability");
1728 spaceBeforePlaceHolder(OS);
1754 if (T->
getAttrKind() == attr::ObjCInertUnsafeUnretained)
1758 if (T->
getAttrKind() == attr::NSReturnsRetained &&
1764 OS <<
" [[clang::lifetimebound]]";
1779 OS <<
" [[clang::annotate_type(...)]]";
1784 OS <<
"__arm_streaming";
1787 if (T->
getAttrKind() == attr::ArmStreamingCompatible) {
1788 OS <<
"__arm_streaming_compatible";
1792 OS <<
"__arm_shared_za";
1796 OS <<
"__arm_preserves_za";
1800 OS <<
" __attribute__((";
1802#define TYPE_ATTR(NAME)
1803#define DECL_OR_TYPE_ATTR(NAME)
1804#define ATTR(NAME) case attr::NAME:
1805#include "clang/Basic/AttrList.inc"
1806 llvm_unreachable(
"non-type attribute attached to type");
1808 case attr::BTFTypeTag:
1809 llvm_unreachable(
"BTFTypeTag attribute handled separately");
1811 case attr::OpenCLPrivateAddressSpace:
1812 case attr::OpenCLGlobalAddressSpace:
1813 case attr::OpenCLGlobalDeviceAddressSpace:
1814 case attr::OpenCLGlobalHostAddressSpace:
1815 case attr::OpenCLLocalAddressSpace:
1816 case attr::OpenCLConstantAddressSpace:
1817 case attr::OpenCLGenericAddressSpace:
1818 case attr::HLSLGroupSharedAddressSpace:
1823 case attr::LifetimeBound:
1824 case attr::TypeNonNull:
1825 case attr::TypeNullable:
1826 case attr::TypeNullableResult:
1827 case attr::TypeNullUnspecified:
1829 case attr::ObjCInertUnsafeUnretained:
1830 case attr::ObjCKindOf:
1831 case attr::ObjCOwnership:
1836 case attr::AddressSpace:
1837 case attr::CmseNSCall:
1838 case attr::AnnotateType:
1839 case attr::WebAssemblyFuncref:
1840 case attr::ArmStreaming:
1841 case attr::ArmStreamingCompatible:
1842 case attr::ArmSharedZA:
1843 case attr::ArmPreservesZA:
1844 llvm_unreachable(
"This attribute should have been handled already");
1846 case attr::NSReturnsRetained:
1847 OS <<
"ns_returns_retained";
1852 case attr::AnyX86NoCfCheck: OS <<
"nocf_check";
break;
1853 case attr::CDecl: OS <<
"cdecl";
break;
1854 case attr::FastCall: OS <<
"fastcall";
break;
1855 case attr::StdCall: OS <<
"stdcall";
break;
1856 case attr::ThisCall: OS <<
"thiscall";
break;
1857 case attr::SwiftCall: OS <<
"swiftcall";
break;
1858 case attr::SwiftAsyncCall: OS <<
"swiftasynccall";
break;
1859 case attr::VectorCall: OS <<
"vectorcall";
break;
1860 case attr::Pascal: OS <<
"pascal";
break;
1861 case attr::MSABI: OS <<
"ms_abi";
break;
1862 case attr::SysVABI: OS <<
"sysv_abi";
break;
1863 case attr::RegCall: OS <<
"regcall";
break;
1870 "\"aapcs\"" :
"\"aapcs-vfp\"");
1874 case attr::AArch64VectorPcs: OS <<
"aarch64_vector_pcs";
break;
1875 case attr::AArch64SVEPcs: OS <<
"aarch64_sve_pcs";
break;
1876 case attr::AMDGPUKernelCall: OS <<
"amdgpu_kernel";
break;
1877 case attr::IntelOclBicc: OS <<
"inteloclbicc";
break;
1878 case attr::PreserveMost:
1879 OS <<
"preserve_most";
1882 case attr::PreserveAll:
1883 OS <<
"preserve_all";
1891 case attr::AcquireHandle:
1892 OS <<
"acquire_handle";
1894 case attr::ArmMveStrictPolymorphism:
1895 OS <<
"__clang_arm_mve_strict_polymorphism";
1899 case attr::HLSLParamModifier:
1908 OS <<
" __attribute__((btf_type_tag(\"" << T->
getAttr()->getBTFTypeTag() <<
"\")))";
1919 spaceBeforePlaceHolder(OS);
1929 bool isFirst =
true;
1931 for (
const auto *I : T->
quals()) {
1941 spaceBeforePlaceHolder(OS);
1959 bool isFirst =
true;
1967 print(typeArg, OS, StringRef());
1973 bool isFirst =
true;
1975 for (
const auto *I : T->
quals()) {
1985 spaceBeforePlaceHolder(OS);
2002 if (HasEmptyPlaceHolder)
2019 llvm::raw_ostream &OS,
bool IncludeType) {
2020 A.
print(PP, OS, IncludeType);
2044 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2047 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2059 if (TQual != PatQual)
2077 Template = TTST->getTemplateName();
2078 TemplateArgs = TTST->template_arguments();
2079 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2081 Template =
TemplateName(CTSD->getSpecializedTemplate());
2082 TemplateArgs = CTSD->getTemplateArgs().asArray();
2090 if (TemplateArgs.size() != PTST->template_arguments().size())
2092 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2094 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2145 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2146 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2147 Args[NTTP->getIndex()].structurallyEquals(Arg);
2163 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2164 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2181 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2182 return TTPD->hasDefaultArgument() &&
2185 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2186 return TTPD->hasDefaultArgument() &&
2188 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2189 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2190 return NTTPD->hasDefaultArgument() &&
2197template <
typename TA>
2204 Args.size() <= TPL->
size()) {
2206 for (
const TA &A : Args)
2209 Args = Args.drop_back();
2216 bool NeedSpace =
false;
2217 bool FirstArg =
true;
2218 for (
const auto &Arg : Args) {
2221 llvm::raw_svector_ostream ArgOS(Buf);
2234 Policy, TPL, ParmIndex));
2236 StringRef ArgString = ArgOS.str();
2241 if (FirstArg && !ArgString.empty() && ArgString[0] ==
':')
2248 if (!ArgString.empty()) {
2276 printTo(OS, Args, Policy, TPL,
false, 0);
2283 printTo(OS, Args, Policy, TPL,
false, 0);
2296 llvm::raw_svector_ostream StrOS(Buf);
2297 print(StrOS, Policy);
2298 return std::string(StrOS.str());
2332 return "__constant";
2337 return "__global_device";
2340 return "__global_host";
2342 return "__device__";
2344 return "__constant__";
2346 return "__shared__";
2348 return "__sptr __ptr32";
2350 return "__uptr __ptr32";
2356 return "groupshared";
2366 bool appendSpaceIfNonEmpty)
const {
2367 bool addSpace =
false;
2377 OS <<
"__unaligned";
2381 if (!ASStr.empty()) {
2387 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2421 if (appendSpaceIfNonEmpty && addSpace)
2443 const Twine &PlaceHolder,
unsigned Indentation)
const {
2450 const Twine &PlaceHolder,
unsigned Indentation) {
2452 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2454 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2464 std::string &buffer,
2467 llvm::raw_svector_ostream StrOS(Buf);
2468 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2469 std::string str = std::string(StrOS.str());
2475 TypePrinter(
LangOptions()).print(S.Ty, S.Quals, OS,
"");
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static void printTo(raw_ostream &OS, ArrayRef< TA > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex)
static const TemplateArgument & getArgument(const TemplateArgument &A)
static bool isSubstitutedType(ASTContext &Ctx, QualType T, QualType Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP, llvm::raw_ostream &OS, bool IncludeType)
static QualType skipTopLevelReferences(QualType T)
static SplitQualType splitAccordingToPolicy(QualType QT, const PrintingPolicy &Policy)
static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg, TemplateArgument Pattern, ArrayRef< TemplateArgument > Args, unsigned Depth)
static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, bool HasRestrictKeyword)
static bool templateArgumentExpressionsEqual(ASTContext const &Ctx, TemplateArgument const &Pattern, TemplateArgument const &Arg)
Evaluates the expression template argument 'Pattern' and returns true if 'Arg' evaluates to the same ...
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
QualType getAdjustedType() const
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
bool isMSTypeSpec() const
QualType getEquivalentType() const
bool isWebAssemblyFuncrefSpec() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
bool isConstrained() const
const BTFTypeTagAttr * getAttr() const
QualType getWrappedType() const
A fixed int type of a specified bitwidth.
unsigned getNumBits() const
QualType getPointeeType() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
bool isFunctionOrMethod() const
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
The name of a declaration.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Represents the type decltype(expr) (C++11).
Expr * getUnderlyingExpr() const
Represents a C++17 deduced template specialization type.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Represents an extended address space qualifier where the input address space value is dependent.
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
Expr * getNumBitsExpr() const
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Represents an array type in C++ whose size is a value-dependent expression.
Expr * getSizeExpr() const
Represents an extended vector type where either the type or size is dependent.
Expr * getSizeExpr() const
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getColumnExpr() const
Expr * getRowExpr() const
Represents a template specialization type whose template cannot be resolved, e.g.
const IdentifierInfo * getIdentifier() const
ArrayRef< TemplateArgument > template_arguments() const
NestedNameSpecifier * getQualifier() const
Represents a vector type where either the type or size is dependent.
Expr * getSizeExpr() const
VectorKind getVectorKind() const
QualType getElementType() const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if there is...
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
ExtVectorType - Extended vector type.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
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().
unsigned getNumExceptions() const
Return the number of types in the exception specification.
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getCmseNSCall() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
bool getProducesResult() const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
QualType getReturnType() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
@ SME_PStateZAPreservedMask
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Represents a C array with an unspecified size.
The injected class name of a C++ class template or class template partial specialization.
const TemplateSpecializationType * getInjectedTST() const
TemplateName getTemplateName() const
An lvalue reference type, per C++11 [dcl.ref].
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
const IdentifierInfo * getMacroIdentifier() const
QualType getElementType() const
Returns type of the elements being stored in the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
const Type * getClass() const
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Represents a pointer to an Objective C object.
bool isObjCQualifiedClassType() const
True if this is equivalent to 'Class.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
bool isUnspecializedAsWritten() const
Determine whether this object type is "unspecialized" as written, meaning that it has no type argumen...
QualType getBaseType() const
Gets the base type of this object type.
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
Represents a type parameter type in Objective C.
ObjCTypeParamDecl * getDecl() const
Represents a pack expansion of types.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Sugar for parentheses used when specifying types.
QualType getInnerType() const
QualType getElementType() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getCanonicalType() const
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
std::string getAsString() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool hasUnaligned() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
static std::string getAddrSpaceAsString(LangAS AS)
An rvalue reference type, per C++11 [dcl.ref].
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeTypeAsWritten() const
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Represents the result of substituting a set of types for a template type parameter pack.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the result of substituting a type for a template type parameter.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Represents the declaration of a struct/union/class/enum.
StringRef getKindName() const
TypedefNameDecl * getTypedefNameForAnonDecl() const
A convenient class for passing around template argument information.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ArgKind
The kind of template argument we're storing.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
@ Type
The template argument is a type.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
ArrayRef< TemplateArgument > template_arguments() const
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Declaration of a template type parameter.
unsigned getIndex() const
Retrieve the index of the template parameter.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
unsigned getDepth() const
Retrieve the depth of the template parameter.
TemplateTypeParmDecl * getDecl() const
unsigned getIndex() const
IdentifierInfo * getIdentifier() const
unsigned getDepth() const
const Type * getTypeForDecl() const
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
Expr * getUnderlyingExpr() const
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
QualType getUnmodifiedType() const
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
ElaboratedTypeKeyword getKeyword() const
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
const T * castAs() const
Member-template castAs<specific type>.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isObjCIdType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isFunctionType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
TypedefNameDecl * getDecl() const
Represents the dependent type named by a dependently-scoped typename using declaration,...
UnresolvedUsingTypenameDecl * getDecl() const
UsingShadowDecl * getFoundDecl() const
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
@ GNUAutoType
__auto_type (GNU extension)
@ DecltypeAuto
decltype(auto)
llvm::StringRef getParameterABISpelling(ParameterABI kind)
bool isTargetAddressSpace(LangAS AS)
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
unsigned toTargetAddressSpace(LangAS AS)
ParameterABI
Kinds of parameter ABI.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
LangAS
Defines the address space values used by the address space qualifier of QualType.
bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg, const NamedDecl *Param, ArrayRef< TemplateArgument > Args, unsigned Depth)
Make a best-effort determination of whether the type T can be produced by substituting Args into the ...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ None
No keyword precedes the qualified type name.
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_MSAny
Microsoft throw(...) extension.
Describes how types, statements, expressions, and declarations should be printed.
unsigned MSVCFormatting
Use whitespace and punctuation like MSVC does.
unsigned SuppressDefaultTemplateArgs
When true, attempt to suppress template arguments that match the default argument for the parameter.
unsigned SplitTemplateClosers
Whether nested templates must be closed like 'a<b<c> >' rather than 'a<b<c>>'.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned Restrict
Whether we can use 'restrict' rather than '__restrict'.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
unsigned SuppressLifetimeQualifiers
When true, suppress printing of lifetime qualifier in ARC.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.