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;
299 case Type::PackIndexing: {
300 return canPrefixQualifiers(
301 cast<PackIndexingType>(UnderlyingType)->getPattern().getTypePtr(),
302 NeedARCStrongQualifier);
306 return CanPrefixQualifiers;
309void TypePrinter::printBefore(
QualType T, raw_ostream &OS) {
315 if (
const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(
Split.Ty))
318 printBefore(
Split.Ty, Quals, OS);
323void TypePrinter::printBefore(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
331 bool CanPrefixQualifiers =
false;
332 bool NeedARCStrongQualifier =
false;
333 CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
335 if (CanPrefixQualifiers && !Quals.
empty()) {
336 if (NeedARCStrongQualifier) {
337 IncludeStrongLifetimeRAII Strong(Policy);
338 Quals.
print(OS, Policy,
true);
340 Quals.
print(OS, Policy,
true);
344 bool hasAfterQuals =
false;
345 if (!CanPrefixQualifiers && !Quals.
empty()) {
348 HasEmptyPlaceHolder =
false;
352#define ABSTRACT_TYPE(CLASS, PARENT)
353#define TYPE(CLASS, PARENT) case Type::CLASS: \
354 print##CLASS##Before(cast<CLASS##Type>(T), OS); \
356#include "clang/AST/TypeNodes.inc"
360 if (NeedARCStrongQualifier) {
361 IncludeStrongLifetimeRAII Strong(Policy);
362 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
364 Quals.
print(OS, Policy, !PrevPHIsEmpty.get());
369void TypePrinter::printAfter(
QualType t, raw_ostream &OS) {
371 printAfter(split.
Ty, split.
Quals, OS);
376void TypePrinter::printAfter(
const Type *T,
Qualifiers Quals, raw_ostream &OS) {
378#define ABSTRACT_TYPE(CLASS, PARENT)
379#define TYPE(CLASS, PARENT) case Type::CLASS: \
380 print##CLASS##After(cast<CLASS##Type>(T), OS); \
382#include "clang/AST/TypeNodes.inc"
386void TypePrinter::printBuiltinBefore(
const BuiltinType *T, raw_ostream &OS) {
388 spaceBeforePlaceHolder(OS);
391void TypePrinter::printBuiltinAfter(
const BuiltinType *T, raw_ostream &OS) {}
393void TypePrinter::printComplexBefore(
const ComplexType *T, raw_ostream &OS) {
398void TypePrinter::printComplexAfter(
const ComplexType *T, raw_ostream &OS) {
402void TypePrinter::printPointerBefore(
const PointerType *T, raw_ostream &OS) {
403 IncludeStrongLifetimeRAII Strong(Policy);
413void TypePrinter::printPointerAfter(
const PointerType *T, raw_ostream &OS) {
414 IncludeStrongLifetimeRAII Strong(Policy);
446 IncludeStrongLifetimeRAII Strong(Policy);
449 printBefore(Inner, OS);
452 if (isa<ArrayType>(Inner))
459 IncludeStrongLifetimeRAII Strong(Policy);
464 if (isa<ArrayType>(Inner))
466 printAfter(Inner, OS);
471 IncludeStrongLifetimeRAII Strong(Policy);
474 printBefore(Inner, OS);
477 if (isa<ArrayType>(Inner))
484 IncludeStrongLifetimeRAII Strong(Policy);
489 if (isa<ArrayType>(Inner))
491 printAfter(Inner, OS);
496 IncludeStrongLifetimeRAII Strong(Policy);
505 InnerPolicy.IncludeTagDefinition =
false;
506 TypePrinter(InnerPolicy).print(
QualType(T->
getClass(), 0), OS, StringRef());
513 IncludeStrongLifetimeRAII Strong(Policy);
524 IncludeStrongLifetimeRAII Strong(Policy);
540 OS << T->
getSize().getZExtValue() <<
']';
546 IncludeStrongLifetimeRAII Strong(Policy);
558 IncludeStrongLifetimeRAII Strong(Policy);
582void TypePrinter::printAdjustedBefore(
const AdjustedType *T, raw_ostream &OS) {
588void TypePrinter::printAdjustedAfter(
const AdjustedType *T, raw_ostream &OS) {
592void TypePrinter::printDecayedBefore(
const DecayedType *T, raw_ostream &OS) {
594 printAdjustedBefore(T, OS);
597void TypePrinter::printDecayedAfter(
const DecayedType *T, raw_ostream &OS) {
598 printAdjustedAfter(T, OS);
601void TypePrinter::printDependentSizedArrayBefore(
604 IncludeStrongLifetimeRAII Strong(Policy);
608void TypePrinter::printDependentSizedArrayAfter(
618void TypePrinter::printDependentAddressSpaceBefore(
623void TypePrinter::printDependentAddressSpaceAfter(
625 OS <<
" __attribute__((address_space(";
632void TypePrinter::printDependentSizedExtVectorBefore(
638void TypePrinter::printDependentSizedExtVectorAfter(
641 OS <<
" __attribute__((ext_vector_type(";
648void TypePrinter::printVectorBefore(
const VectorType *T, raw_ostream &OS) {
650 case VectorKind::AltiVecPixel:
651 OS <<
"__vector __pixel ";
653 case VectorKind::AltiVecBool:
654 OS <<
"__vector __bool ";
657 case VectorKind::AltiVecVector:
661 case VectorKind::Neon:
662 OS <<
"__attribute__((neon_vector_type("
666 case VectorKind::NeonPoly:
667 OS <<
"__attribute__((neon_polyvector_type(" <<
671 case VectorKind::Generic: {
674 OS <<
"__attribute__((__vector_size__("
682 case VectorKind::SveFixedLengthData:
683 case VectorKind::SveFixedLengthPredicate:
686 OS <<
"__attribute__((__arm_sve_vector_bits__(";
688 if (T->
getVectorKind() == VectorKind::SveFixedLengthPredicate)
701 case VectorKind::RVVFixedLengthData:
702 case VectorKind::RVVFixedLengthMask:
705 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
718void TypePrinter::printVectorAfter(
const VectorType *T, raw_ostream &OS) {
722void TypePrinter::printDependentVectorBefore(
725 case VectorKind::AltiVecPixel:
726 OS <<
"__vector __pixel ";
728 case VectorKind::AltiVecBool:
729 OS <<
"__vector __bool ";
732 case VectorKind::AltiVecVector:
736 case VectorKind::Neon:
737 OS <<
"__attribute__((neon_vector_type(";
743 case VectorKind::NeonPoly:
744 OS <<
"__attribute__((neon_polyvector_type(";
750 case VectorKind::Generic: {
753 OS <<
"__attribute__((__vector_size__(";
762 case VectorKind::SveFixedLengthData:
763 case VectorKind::SveFixedLengthPredicate:
766 OS <<
"__attribute__((__arm_sve_vector_bits__(";
769 if (T->
getVectorKind() == VectorKind::SveFixedLengthPredicate)
781 case VectorKind::RVVFixedLengthData:
782 case VectorKind::RVVFixedLengthMask:
785 OS <<
"__attribute__((__riscv_rvv_vector_bits__(";
799void TypePrinter::printDependentVectorAfter(
804void TypePrinter::printExtVectorBefore(
const ExtVectorType *T,
809void TypePrinter::printExtVectorAfter(
const ExtVectorType *T, raw_ostream &OS) {
811 OS <<
" __attribute__((ext_vector_type(";
819 OS <<
" __attribute__((matrix_type(";
829void TypePrinter::printDependentSizedMatrixBefore(
832 OS <<
" __attribute__((matrix_type(";
843void TypePrinter::printDependentSizedMatrixAfter(
865 OS <<
" __attribute__((nothrow))";
883 if (!HasEmptyPlaceHolder)
889 if (!PrevPHIsEmpty.get())
897 llvm_unreachable(
"asking for spelling of ordinary parameter ABI");
899 return "swift_context";
901 return "swift_async_context";
903 return "swift_error_result";
905 return "swift_indirect_result";
907 llvm_unreachable(
"bad parameter ABI kind");
913 if (!HasEmptyPlaceHolder)
919 ParamPolicyRAII ParamPolicy(Policy);
920 for (
unsigned i = 0, e = T->
getNumParams(); i != e; ++i) {
924 if (EPI.isConsumed()) OS <<
"__attribute__((ns_consumed)) ";
925 if (EPI.isNoEscape())
926 OS <<
"__attribute__((noescape)) ";
927 auto ABI = EPI.getABI();
939 }
else if (T->
getNumParams() == 0 && Policy.UseVoidForZeroParams) {
950 OS <<
" __arm_streaming_compatible";
952 OS <<
" __arm_streaming";
954 OS <<
" __arm_preserves(\"za\")";
956 OS <<
" __arm_in(\"za\")";
958 OS <<
" __arm_out(\"za\")";
960 OS <<
" __arm_inout(\"za\")";
962 OS <<
" __arm_preserves(\"zt0\")";
964 OS <<
" __arm_in(\"zt0\")";
966 OS <<
" __arm_out(\"zt0\")";
968 OS <<
" __arm_inout(\"zt0\")";
970 printFunctionAfter(Info, OS);
998 if (!InsideCCAttribute) {
999 switch (Info.
getCC()) {
1010 OS <<
" __attribute__((stdcall))";
1013 OS <<
" __attribute__((fastcall))";
1016 OS <<
" __attribute__((thiscall))";
1019 OS <<
" __attribute__((vectorcall))";
1022 OS <<
" __attribute__((pascal))";
1025 OS <<
" __attribute__((pcs(\"aapcs\")))";
1028 OS <<
" __attribute__((pcs(\"aapcs-vfp\")))";
1031 OS <<
"__attribute__((aarch64_vector_pcs))";
1034 OS <<
"__attribute__((aarch64_sve_pcs))";
1037 OS <<
"__attribute__((amdgpu_kernel))";
1040 OS <<
" __attribute__((intel_ocl_bicc))";
1043 OS <<
" __attribute__((ms_abi))";
1046 OS <<
" __attribute__((sysv_abi))";
1049 OS <<
" __attribute__((regcall))";
1056 OS <<
" __attribute__((swiftcall))";
1059 OS <<
"__attribute__((swiftasynccall))";
1062 OS <<
" __attribute__((preserve_most))";
1065 OS <<
" __attribute__((preserve_all))";
1068 OS <<
" __attribute__((m68k_rtd))";
1071 OS <<
" __attribute__((preserve_none))";
1077 OS <<
" __attribute__((noreturn))";
1079 OS <<
" __attribute__((cmse_nonsecure_call))";
1081 OS <<
" __attribute__((ns_returns_retained))";
1083 OS <<
" __attribute__((regparm ("
1086 OS <<
" __attribute__((no_caller_saved_registers))";
1088 OS <<
" __attribute__((nocf_check))";
1096 if (!PrevPHIsEmpty.get())
1103 if (!HasEmptyPlaceHolder)
1112void TypePrinter::printTypeSpec(
NamedDecl *D, raw_ostream &OS) {
1117 if (!Policy.SuppressScope)
1122 spaceBeforePlaceHolder(OS);
1127 printTypeSpec(T->
getDecl(), OS);
1133void TypePrinter::printUsingBefore(
const UsingType *T, raw_ostream &OS) {
1146void TypePrinter::printUsingAfter(
const UsingType *T, raw_ostream &OS) {}
1148void TypePrinter::printTypedefBefore(
const TypedefType *T, raw_ostream &OS) {
1149 printTypeSpec(T->
getDecl(), OS);
1155 OS << MacroName <<
" ";
1167void TypePrinter::printTypedefAfter(
const TypedefType *T, raw_ostream &OS) {}
1175 spaceBeforePlaceHolder(OS);
1181void TypePrinter::printTypeOfBefore(
const TypeOfType *T, raw_ostream &OS) {
1186 spaceBeforePlaceHolder(OS);
1189void TypePrinter::printTypeOfAfter(
const TypeOfType *T, raw_ostream &OS) {}
1191void TypePrinter::printDecltypeBefore(
const DecltypeType *T, raw_ostream &OS) {
1196 spaceBeforePlaceHolder(OS);
1205 spaceBeforePlaceHolder(OS);
1211void TypePrinter::printDecltypeAfter(
const DecltypeType *T, raw_ostream &OS) {}
1215 IncludeStrongLifetimeRAII Strong(Policy);
1217 static llvm::DenseMap<int, const char *> Transformation = {{
1218#define TRANSFORM_TYPE_TRAIT_DEF(Enum, Trait) \
1219 {UnaryTransformType::Enum, "__" #Trait},
1220#include "clang/Basic/TransformTypeTraits.def"
1222 OS << Transformation[T->
getUTTKind()] <<
'(';
1225 spaceBeforePlaceHolder(OS);
1231void TypePrinter::printAutoBefore(
const AutoType *T, raw_ostream &OS) {
1252 spaceBeforePlaceHolder(OS);
1256void TypePrinter::printAutoAfter(
const AutoType *T, raw_ostream &OS) {
1262void TypePrinter::printDeducedTemplateSpecializationBefore(
1268 IncludeStrongLifetimeRAII Strong(Policy);
1270 spaceBeforePlaceHolder(OS);
1274void TypePrinter::printDeducedTemplateSpecializationAfter(
1281void TypePrinter::printAtomicBefore(
const AtomicType *T, raw_ostream &OS) {
1282 IncludeStrongLifetimeRAII Strong(Policy);
1287 spaceBeforePlaceHolder(OS);
1290void TypePrinter::printAtomicAfter(
const AtomicType *T, raw_ostream &OS) {}
1292void TypePrinter::printPipeBefore(
const PipeType *T, raw_ostream &OS) {
1293 IncludeStrongLifetimeRAII Strong(Policy);
1298 OS <<
"write_only ";
1301 spaceBeforePlaceHolder(OS);
1304void TypePrinter::printPipeAfter(
const PipeType *T, raw_ostream &OS) {}
1306void TypePrinter::printBitIntBefore(
const BitIntType *T, raw_ostream &OS) {
1310 spaceBeforePlaceHolder(OS);
1313void TypePrinter::printBitIntAfter(
const BitIntType *T, raw_ostream &OS) {}
1322 spaceBeforePlaceHolder(OS);
1329void TypePrinter::AppendScope(
DeclContext *DC, raw_ostream &OS,
1339 if (Policy.Callbacks && Policy.Callbacks->isScopeVisible(DC))
1342 if (
const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1343 if (Policy.SuppressUnwrittenScope && NS->isAnonymousNamespace())
1344 return AppendScope(DC->
getParent(), OS, NameInScope);
1348 if (Policy.SuppressInlineNamespace && NS->isInline() && NameInScope &&
1349 NS->isRedundantInlineQualifierFor(NameInScope))
1350 return AppendScope(DC->
getParent(), OS, NameInScope);
1352 AppendScope(DC->
getParent(), OS, NS->getDeclName());
1353 if (NS->getIdentifier())
1354 OS << NS->getName() <<
"::";
1356 OS <<
"(anonymous namespace)::";
1357 }
else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1358 AppendScope(DC->
getParent(), OS, Spec->getDeclName());
1359 IncludeStrongLifetimeRAII Strong(Policy);
1360 OS << Spec->getIdentifier()->getName();
1363 OS, TemplateArgs.
asArray(), Policy,
1364 Spec->getSpecializedTemplate()->getTemplateParameters());
1366 }
else if (
const auto *Tag = dyn_cast<TagDecl>(DC)) {
1367 AppendScope(DC->
getParent(), OS, Tag->getDeclName());
1369 OS << Typedef->getIdentifier()->getName() <<
"::";
1370 else if (Tag->getIdentifier())
1371 OS << Tag->getIdentifier()->getName() <<
"::";
1375 AppendScope(DC->
getParent(), OS, NameInScope);
1379void TypePrinter::printTag(
TagDecl *D, raw_ostream &OS) {
1380 if (Policy.IncludeTagDefinition) {
1383 D->
print(OS, SubPolicy, Indentation);
1384 spaceBeforePlaceHolder(OS);
1388 bool HasKindDecoration =
false;
1393 HasKindDecoration =
true;
1401 if (!Policy.SuppressScope)
1407 assert(Typedef->getIdentifier() &&
"Typedef without identifier?");
1408 OS << Typedef->getIdentifier()->getName();
1412 OS << (Policy.MSVCFormatting ?
'`' :
'(');
1414 if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) {
1416 HasKindDecoration =
true;
1417 }
else if ((isa<RecordDecl>(D) && cast<RecordDecl>(D)->isAnonymousStructOrUnion())) {
1423 if (Policy.AnonymousTagLocations) {
1427 if (!HasKindDecoration)
1436 if (
auto *Callbacks = Policy.Callbacks)
1437 WrittenFile = Callbacks->remapPath(
File);
1441 llvm::sys::path::Style Style =
1442 llvm::sys::path::is_absolute(WrittenFile)
1443 ? llvm::sys::path::Style::native
1444 : (Policy.MSVCFormatting
1445 ? llvm::sys::path::Style::windows_backslash
1446 : llvm::sys::path::Style::posix);
1447 llvm::sys::path::native(WrittenFile, Style);
1452 OS << (Policy.MSVCFormatting ?
'\'' :
')');
1457 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1460 if (!Policy.PrintCanonicalTypes && TAW) {
1462 cast<TemplateSpecializationType>(TAW->
getType());
1466 Args = TemplateArgs.
asArray();
1468 IncludeStrongLifetimeRAII Strong(Policy);
1471 Spec->getSpecializedTemplate()->getTemplateParameters());
1474 spaceBeforePlaceHolder(OS);
1477void TypePrinter::printRecordBefore(
const RecordType *T, raw_ostream &OS) {
1479 if (Policy.UsePreferredNames) {
1485 QualType T = PNA->getTypedefType();
1487 if (
auto *TT = dyn_cast<TypedefType>(T))
1488 return printTypeSpec(TT->getDecl(), OS);
1489 if (
auto *TST = dyn_cast<TemplateSpecializationType>(T))
1490 return printTemplateId(TST, OS,
true);
1496 printTag(T->getDecl(), OS);
1499void TypePrinter::printRecordAfter(
const RecordType *T, raw_ostream &OS) {}
1501void TypePrinter::printEnumBefore(
const EnumType *T, raw_ostream &OS) {
1505void TypePrinter::printEnumAfter(
const EnumType *T, raw_ostream &OS) {}
1512 TC->
print(OS, Policy);
1517 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1522 spaceBeforePlaceHolder(OS);
1528void TypePrinter::printSubstTemplateTypeParmBefore(
1531 IncludeStrongLifetimeRAII Strong(Policy);
1535void TypePrinter::printSubstTemplateTypeParmAfter(
1538 IncludeStrongLifetimeRAII Strong(Policy);
1542void TypePrinter::printSubstTemplateTypeParmPackBefore(
1545 IncludeStrongLifetimeRAII Strong(Policy);
1549 TC->print(OS, Policy);
1554 OS << (Policy.CleanUglifiedParameters ?
Id->deuglifiedName()
1559 spaceBeforePlaceHolder(OS);
1563void TypePrinter::printSubstTemplateTypeParmPackAfter(
1566 IncludeStrongLifetimeRAII Strong(Policy);
1570 raw_ostream &OS,
bool FullyQualify) {
1571 IncludeStrongLifetimeRAII Strong(Policy);
1575 if (FullyQualify && TD) {
1576 if (!Policy.SuppressScope)
1584 DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
1587 spaceBeforePlaceHolder(OS);
1590void TypePrinter::printTemplateSpecializationBefore(
1593 printTemplateId(T, OS, Policy.FullyQualifiedName);
1596void TypePrinter::printTemplateSpecializationAfter(
1602 if (Policy.PrintInjectedClassNameWithArguments)
1603 return printTemplateSpecializationBefore(T->
getInjectedTST(), OS);
1605 IncludeStrongLifetimeRAII Strong(Policy);
1607 spaceBeforePlaceHolder(OS);
1618 "OwnedTagDecl expected to be a declaration for the type");
1621 OwnedTagDecl->
print(OS, SubPolicy, Indentation);
1622 spaceBeforePlaceHolder(OS);
1626 if (Policy.SuppressElaboration) {
1632 if (!Policy.IncludeTagDefinition)
1642 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1651 if (Policy.SuppressElaboration) {
1656 ElaboratedTypePolicyRAII PolicyRAII(Policy);
1660void TypePrinter::printParenBefore(
const ParenType *T, raw_ostream &OS) {
1661 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1668void TypePrinter::printParenAfter(
const ParenType *T, raw_ostream &OS) {
1669 if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->
getInnerType())) {
1685 spaceBeforePlaceHolder(OS);
1691void TypePrinter::printDependentTemplateSpecializationBefore(
1693 IncludeStrongLifetimeRAII Strong(Policy);
1703 spaceBeforePlaceHolder(OS);
1706void TypePrinter::printDependentTemplateSpecializationAfter(
1740 case attr::Ptr32: OS <<
" __ptr32";
break;
1741 case attr::Ptr64: OS <<
" __ptr64";
break;
1742 case attr::SPtr: OS <<
" __sptr";
break;
1743 case attr::UPtr: OS <<
" __uptr";
break;
1745 spaceBeforePlaceHolder(OS);
1757 else if (T->
getAttrKind() == attr::TypeNullUnspecified)
1758 OS <<
" _Null_unspecified";
1759 else if (T->
getAttrKind() == attr::TypeNullableResult)
1760 OS <<
" _Nullable_result";
1762 llvm_unreachable(
"unhandled nullability");
1763 spaceBeforePlaceHolder(OS);
1789 if (T->
getAttrKind() == attr::ObjCInertUnsafeUnretained)
1793 if (T->
getAttrKind() == attr::NSReturnsRetained &&
1799 OS <<
" [[clang::lifetimebound]]";
1814 OS <<
" [[clang::annotate_type(...)]]";
1819 OS <<
"__arm_streaming";
1822 if (T->
getAttrKind() == attr::ArmStreamingCompatible) {
1823 OS <<
"__arm_streaming_compatible";
1827 OS <<
" __attribute__((";
1829#define TYPE_ATTR(NAME)
1830#define DECL_OR_TYPE_ATTR(NAME)
1831#define ATTR(NAME) case attr::NAME:
1832#include "clang/Basic/AttrList.inc"
1833 llvm_unreachable(
"non-type attribute attached to type");
1835 case attr::BTFTypeTag:
1836 llvm_unreachable(
"BTFTypeTag attribute handled separately");
1838 case attr::OpenCLPrivateAddressSpace:
1839 case attr::OpenCLGlobalAddressSpace:
1840 case attr::OpenCLGlobalDeviceAddressSpace:
1841 case attr::OpenCLGlobalHostAddressSpace:
1842 case attr::OpenCLLocalAddressSpace:
1843 case attr::OpenCLConstantAddressSpace:
1844 case attr::OpenCLGenericAddressSpace:
1845 case attr::HLSLGroupSharedAddressSpace:
1850 case attr::LifetimeBound:
1851 case attr::TypeNonNull:
1852 case attr::TypeNullable:
1853 case attr::TypeNullableResult:
1854 case attr::TypeNullUnspecified:
1856 case attr::ObjCInertUnsafeUnretained:
1857 case attr::ObjCKindOf:
1858 case attr::ObjCOwnership:
1863 case attr::AddressSpace:
1864 case attr::CmseNSCall:
1865 case attr::AnnotateType:
1866 case attr::WebAssemblyFuncref:
1867 case attr::ArmStreaming:
1868 case attr::ArmStreamingCompatible:
1871 case attr::ArmInOut:
1872 case attr::ArmPreserves:
1873 llvm_unreachable(
"This attribute should have been handled already");
1875 case attr::NSReturnsRetained:
1876 OS <<
"ns_returns_retained";
1881 case attr::AnyX86NoCfCheck: OS <<
"nocf_check";
break;
1882 case attr::CDecl: OS <<
"cdecl";
break;
1883 case attr::FastCall: OS <<
"fastcall";
break;
1884 case attr::StdCall: OS <<
"stdcall";
break;
1885 case attr::ThisCall: OS <<
"thiscall";
break;
1886 case attr::SwiftCall: OS <<
"swiftcall";
break;
1887 case attr::SwiftAsyncCall: OS <<
"swiftasynccall";
break;
1888 case attr::VectorCall: OS <<
"vectorcall";
break;
1889 case attr::Pascal: OS <<
"pascal";
break;
1890 case attr::MSABI: OS <<
"ms_abi";
break;
1891 case attr::SysVABI: OS <<
"sysv_abi";
break;
1892 case attr::RegCall: OS <<
"regcall";
break;
1899 "\"aapcs\"" :
"\"aapcs-vfp\"");
1903 case attr::AArch64VectorPcs: OS <<
"aarch64_vector_pcs";
break;
1904 case attr::AArch64SVEPcs: OS <<
"aarch64_sve_pcs";
break;
1905 case attr::AMDGPUKernelCall: OS <<
"amdgpu_kernel";
break;
1906 case attr::IntelOclBicc: OS <<
"inteloclbicc";
break;
1907 case attr::PreserveMost:
1908 OS <<
"preserve_most";
1911 case attr::PreserveAll:
1912 OS <<
"preserve_all";
1917 case attr::PreserveNone:
1918 OS <<
"preserve_none";
1923 case attr::AcquireHandle:
1924 OS <<
"acquire_handle";
1926 case attr::ArmMveStrictPolymorphism:
1927 OS <<
"__clang_arm_mve_strict_polymorphism";
1931 case attr::HLSLParamModifier:
1940 OS <<
" __attribute__((btf_type_tag(\"" << T->
getAttr()->getBTFTypeTag() <<
"\")))";
1951 spaceBeforePlaceHolder(OS);
1961 bool isFirst =
true;
1963 for (
const auto *I : T->
quals()) {
1973 spaceBeforePlaceHolder(OS);
1991 bool isFirst =
true;
1999 print(typeArg, OS, StringRef());
2005 bool isFirst =
true;
2007 for (
const auto *I : T->
quals()) {
2017 spaceBeforePlaceHolder(OS);
2034 if (HasEmptyPlaceHolder)
2051 llvm::raw_ostream &OS,
bool IncludeType) {
2052 A.
print(PP, OS, IncludeType);
2076 if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
2079 Args[TTPT->getIndex()].getAsType(), Pattern.
getQualifiers());
2091 if (TQual != PatQual)
2109 Template = TTST->getTemplateName();
2110 TemplateArgs = TTST->template_arguments();
2111 }
else if (
auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2113 Template =
TemplateName(CTSD->getSpecializedTemplate());
2114 TemplateArgs = CTSD->getTemplateArgs().asArray();
2122 if (TemplateArgs.size() != PTST->template_arguments().size())
2124 for (
unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
2126 Ctx, TemplateArgs[I], PTST->template_arguments()[I], Args, Depth))
2177 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
2178 return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
2179 Args[NTTP->getIndex()].structurallyEquals(Arg);
2195 if (
auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2196 return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2213 if (
auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2214 return TTPD->hasDefaultArgument() &&
2217 }
else if (
auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2218 return TTPD->hasDefaultArgument() &&
2220 Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2221 }
else if (
auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2222 return NTTPD->hasDefaultArgument() &&
2229template <
typename TA>
2236 Args.size() <= TPL->
size()) {
2238 for (
const TA &A : Args)
2241 Args = Args.drop_back();
2248 bool NeedSpace =
false;
2249 bool FirstArg =
true;
2250 for (
const auto &Arg : Args) {
2253 llvm::raw_svector_ostream ArgOS(Buf);
2266 Policy, TPL, ParmIndex));
2268 StringRef ArgString = ArgOS.str();
2273 if (FirstArg && ArgString.starts_with(
":"))
2280 if (!ArgString.empty()) {
2308 printTo(OS, Args, Policy, TPL,
false, 0);
2315 printTo(OS, Args, Policy, TPL,
false, 0);
2328 llvm::raw_svector_ostream StrOS(Buf);
2329 print(StrOS, Policy);
2330 return std::string(StrOS.str());
2364 return "__constant";
2369 return "__global_device";
2372 return "__global_host";
2374 return "__device__";
2376 return "__constant__";
2378 return "__shared__";
2380 return "__sptr __ptr32";
2382 return "__uptr __ptr32";
2388 return "groupshared";
2398 bool appendSpaceIfNonEmpty)
const {
2399 bool addSpace =
false;
2409 OS <<
"__unaligned";
2413 if (!ASStr.empty()) {
2419 OS <<
"__attribute__((address_space(" << ASStr <<
")))";
2453 if (appendSpaceIfNonEmpty && addSpace)
2475 const Twine &PlaceHolder,
unsigned Indentation)
const {
2482 const Twine &PlaceHolder,
unsigned Indentation) {
2484 StringRef PH = PlaceHolder.toStringRef(PHBuf);
2486 TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2496 std::string &buffer,
2499 llvm::raw_svector_ostream StrOS(Buf);
2500 TypePrinter(policy).print(ty, qs, StrOS, buffer);
2501 std::string str = std::string(StrOS.str());
2507 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
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
@ SME_PStateSMEnabledMask
@ SME_PStateSMCompatibleMask
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...
bool hasSelectedType() const
QualType getPattern() const
QualType getSelectedType() const
Expr * getIndexExpr() const
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
The JSON file list parser is used to communicate input to InstallAPI.
@ 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.