clang  15.0.0git
TypePrinter.cpp
Go to the documentation of this file.
1 //===- TypePrinter.cpp - Pretty-Print Clang Types -------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This contains code to print types from Clang's type system.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/Attr.h"
15 #include "clang/AST/Decl.h"
16 #include "clang/AST/DeclBase.h"
17 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/DeclObjC.h"
19 #include "clang/AST/DeclTemplate.h"
20 #include "clang/AST/Expr.h"
23 #include "clang/AST/TemplateBase.h"
24 #include "clang/AST/TemplateName.h"
25 #include "clang/AST/Type.h"
29 #include "clang/Basic/LLVM.h"
33 #include "clang/Basic/Specifiers.h"
34 #include "llvm/ADT/ArrayRef.h"
35 #include "llvm/ADT/SmallString.h"
36 #include "llvm/ADT/StringRef.h"
37 #include "llvm/ADT/Twine.h"
38 #include "llvm/Support/Casting.h"
39 #include "llvm/Support/Compiler.h"
40 #include "llvm/Support/ErrorHandling.h"
41 #include "llvm/Support/SaveAndRestore.h"
42 #include "llvm/Support/raw_ostream.h"
43 #include <cassert>
44 #include <string>
45 
46 using namespace clang;
47 
48 namespace {
49 
50  /// RAII object that enables printing of the ARC __strong lifetime
51  /// qualifier.
52  class IncludeStrongLifetimeRAII {
53  PrintingPolicy &Policy;
54  bool Old;
55 
56  public:
57  explicit IncludeStrongLifetimeRAII(PrintingPolicy &Policy)
58  : Policy(Policy), Old(Policy.SuppressStrongLifetime) {
59  if (!Policy.SuppressLifetimeQualifiers)
60  Policy.SuppressStrongLifetime = false;
61  }
62 
63  ~IncludeStrongLifetimeRAII() {
64  Policy.SuppressStrongLifetime = Old;
65  }
66  };
67 
68  class ParamPolicyRAII {
69  PrintingPolicy &Policy;
70  bool Old;
71 
72  public:
73  explicit ParamPolicyRAII(PrintingPolicy &Policy)
74  : Policy(Policy), Old(Policy.SuppressSpecifiers) {
75  Policy.SuppressSpecifiers = false;
76  }
77 
78  ~ParamPolicyRAII() {
79  Policy.SuppressSpecifiers = Old;
80  }
81  };
82 
83  class ElaboratedTypePolicyRAII {
84  PrintingPolicy &Policy;
85  bool SuppressTagKeyword;
86  bool SuppressScope;
87 
88  public:
89  explicit ElaboratedTypePolicyRAII(PrintingPolicy &Policy) : Policy(Policy) {
90  SuppressTagKeyword = Policy.SuppressTagKeyword;
91  SuppressScope = Policy.SuppressScope;
92  Policy.SuppressTagKeyword = true;
93  Policy.SuppressScope = true;
94  }
95 
96  ~ElaboratedTypePolicyRAII() {
97  Policy.SuppressTagKeyword = SuppressTagKeyword;
98  Policy.SuppressScope = SuppressScope;
99  }
100  };
101 
102  class TypePrinter {
103  PrintingPolicy Policy;
104  unsigned Indentation;
105  bool HasEmptyPlaceHolder = false;
106  bool InsideCCAttribute = false;
107 
108  public:
109  explicit TypePrinter(const PrintingPolicy &Policy, unsigned Indentation = 0)
110  : Policy(Policy), Indentation(Indentation) {}
111 
112  void print(const Type *ty, Qualifiers qs, raw_ostream &OS,
113  StringRef PlaceHolder);
114  void print(QualType T, raw_ostream &OS, StringRef PlaceHolder);
115 
116  static bool canPrefixQualifiers(const Type *T, bool &NeedARCStrongQualifier);
117  void spaceBeforePlaceHolder(raw_ostream &OS);
118  void printTypeSpec(NamedDecl *D, raw_ostream &OS);
119  void printTemplateId(const TemplateSpecializationType *T, raw_ostream &OS,
120  bool FullyQualify);
121 
122  void printBefore(QualType T, raw_ostream &OS);
123  void printAfter(QualType T, raw_ostream &OS);
124  void AppendScope(DeclContext *DC, raw_ostream &OS,
125  DeclarationName NameInScope);
126  void printTag(TagDecl *T, raw_ostream &OS);
127  void printFunctionAfter(const FunctionType::ExtInfo &Info, raw_ostream &OS);
128 #define ABSTRACT_TYPE(CLASS, PARENT)
129 #define TYPE(CLASS, PARENT) \
130  void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
131  void print##CLASS##After(const CLASS##Type *T, raw_ostream &OS);
132 #include "clang/AST/TypeNodes.inc"
133 
134  private:
135  void printBefore(const Type *ty, Qualifiers qs, raw_ostream &OS);
136  void printAfter(const Type *ty, Qualifiers qs, raw_ostream &OS);
137  };
138 
139 } // namespace
140 
141 static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals,
142  bool HasRestrictKeyword) {
143  bool appendSpace = false;
144  if (TypeQuals & Qualifiers::Const) {
145  OS << "const";
146  appendSpace = true;
147  }
148  if (TypeQuals & Qualifiers::Volatile) {
149  if (appendSpace) OS << ' ';
150  OS << "volatile";
151  appendSpace = true;
152  }
153  if (TypeQuals & Qualifiers::Restrict) {
154  if (appendSpace) OS << ' ';
155  if (HasRestrictKeyword) {
156  OS << "restrict";
157  } else {
158  OS << "__restrict";
159  }
160  }
161 }
162 
163 void TypePrinter::spaceBeforePlaceHolder(raw_ostream &OS) {
164  if (!HasEmptyPlaceHolder)
165  OS << ' ';
166 }
167 
169  const PrintingPolicy &Policy) {
170  if (Policy.PrintCanonicalTypes)
171  QT = QT.getCanonicalType();
172  return QT.split();
173 }
174 
175 void TypePrinter::print(QualType t, raw_ostream &OS, StringRef PlaceHolder) {
176  SplitQualType split = splitAccordingToPolicy(t, Policy);
177  print(split.Ty, split.Quals, OS, PlaceHolder);
178 }
179 
180 void TypePrinter::print(const Type *T, Qualifiers Quals, raw_ostream &OS,
181  StringRef PlaceHolder) {
182  if (!T) {
183  OS << "NULL TYPE";
184  return;
185  }
186 
187  SaveAndRestore<bool> PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
188 
189  printBefore(T, Quals, OS);
190  OS << PlaceHolder;
191  printAfter(T, Quals, OS);
192 }
193 
194 bool TypePrinter::canPrefixQualifiers(const Type *T,
195  bool &NeedARCStrongQualifier) {
196  // CanPrefixQualifiers - We prefer to print type qualifiers before the type,
197  // so that we get "const int" instead of "int const", but we can't do this if
198  // the type is complex. For example if the type is "int*", we *must* print
199  // "int * const", printing "const int *" is different. Only do this when the
200  // type expands to a simple string.
201  bool CanPrefixQualifiers = false;
202  NeedARCStrongQualifier = false;
203  const Type *UnderlyingType = T;
204  if (const auto *AT = dyn_cast<AutoType>(T))
205  UnderlyingType = AT->desugar().getTypePtr();
206  if (const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T))
207  UnderlyingType = Subst->getReplacementType().getTypePtr();
208  Type::TypeClass TC = UnderlyingType->getTypeClass();
209 
210  switch (TC) {
211  case Type::Auto:
212  case Type::Builtin:
213  case Type::Complex:
214  case Type::UnresolvedUsing:
215  case Type::Using:
216  case Type::Typedef:
217  case Type::TypeOfExpr:
218  case Type::TypeOf:
219  case Type::Decltype:
220  case Type::UnaryTransform:
221  case Type::Record:
222  case Type::Enum:
223  case Type::Elaborated:
224  case Type::TemplateTypeParm:
225  case Type::SubstTemplateTypeParmPack:
226  case Type::DeducedTemplateSpecialization:
227  case Type::TemplateSpecialization:
228  case Type::InjectedClassName:
229  case Type::DependentName:
230  case Type::DependentTemplateSpecialization:
231  case Type::ObjCObject:
232  case Type::ObjCTypeParam:
233  case Type::ObjCInterface:
234  case Type::Atomic:
235  case Type::Pipe:
236  case Type::BitInt:
237  case Type::DependentBitInt:
238  case Type::BTFTagAttributed:
239  CanPrefixQualifiers = true;
240  break;
241 
242  case Type::ObjCObjectPointer:
243  CanPrefixQualifiers = T->isObjCIdType() || T->isObjCClassType() ||
245  break;
246 
247  case Type::VariableArray:
248  case Type::DependentSizedArray:
249  NeedARCStrongQualifier = true;
250  LLVM_FALLTHROUGH;
251 
252  case Type::ConstantArray:
253  case Type::IncompleteArray:
254  return canPrefixQualifiers(
255  cast<ArrayType>(UnderlyingType)->getElementType().getTypePtr(),
256  NeedARCStrongQualifier);
257 
258  case Type::Adjusted:
259  case Type::Decayed:
260  case Type::Pointer:
261  case Type::BlockPointer:
262  case Type::LValueReference:
263  case Type::RValueReference:
264  case Type::MemberPointer:
265  case Type::DependentAddressSpace:
266  case Type::DependentVector:
267  case Type::DependentSizedExtVector:
268  case Type::Vector:
269  case Type::ExtVector:
270  case Type::ConstantMatrix:
271  case Type::DependentSizedMatrix:
272  case Type::FunctionProto:
273  case Type::FunctionNoProto:
274  case Type::Paren:
275  case Type::PackExpansion:
276  case Type::SubstTemplateTypeParm:
277  case Type::MacroQualified:
278  CanPrefixQualifiers = false;
279  break;
280 
281  case Type::Attributed: {
282  // We still want to print the address_space before the type if it is an
283  // address_space attribute.
284  const auto *AttrTy = cast<AttributedType>(UnderlyingType);
285  CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace;
286  break;
287  }
288  }
289 
290  return CanPrefixQualifiers;
291 }
292 
293 void TypePrinter::printBefore(QualType T, raw_ostream &OS) {
295 
296  // If we have cv1 T, where T is substituted for cv2 U, only print cv1 - cv2
297  // at this level.
298  Qualifiers Quals = Split.Quals;
299  if (const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(Split.Ty))
300  Quals -= QualType(Subst, 0).getQualifiers();
301 
302  printBefore(Split.Ty, Quals, OS);
303 }
304 
305 /// Prints the part of the type string before an identifier, e.g. for
306 /// "int foo[10]" it prints "int ".
307 void TypePrinter::printBefore(const Type *T,Qualifiers Quals, raw_ostream &OS) {
308  if (Policy.SuppressSpecifiers && T->isSpecifierType())
309  return;
310 
311  SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder);
312 
313  // Print qualifiers as appropriate.
314 
315  bool CanPrefixQualifiers = false;
316  bool NeedARCStrongQualifier = false;
317  CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
318 
319  if (CanPrefixQualifiers && !Quals.empty()) {
320  if (NeedARCStrongQualifier) {
321  IncludeStrongLifetimeRAII Strong(Policy);
322  Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/true);
323  } else {
324  Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/true);
325  }
326  }
327 
328  bool hasAfterQuals = false;
329  if (!CanPrefixQualifiers && !Quals.empty()) {
330  hasAfterQuals = !Quals.isEmptyWhenPrinted(Policy);
331  if (hasAfterQuals)
332  HasEmptyPlaceHolder = false;
333  }
334 
335  switch (T->getTypeClass()) {
336 #define ABSTRACT_TYPE(CLASS, PARENT)
337 #define TYPE(CLASS, PARENT) case Type::CLASS: \
338  print##CLASS##Before(cast<CLASS##Type>(T), OS); \
339  break;
340 #include "clang/AST/TypeNodes.inc"
341  }
342 
343  if (hasAfterQuals) {
344  if (NeedARCStrongQualifier) {
345  IncludeStrongLifetimeRAII Strong(Policy);
346  Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/!PrevPHIsEmpty.get());
347  } else {
348  Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/!PrevPHIsEmpty.get());
349  }
350  }
351 }
352 
353 void TypePrinter::printAfter(QualType t, raw_ostream &OS) {
354  SplitQualType split = splitAccordingToPolicy(t, Policy);
355  printAfter(split.Ty, split.Quals, OS);
356 }
357 
358 /// Prints the part of the type string after an identifier, e.g. for
359 /// "int foo[10]" it prints "[10]".
360 void TypePrinter::printAfter(const Type *T, Qualifiers Quals, raw_ostream &OS) {
361  switch (T->getTypeClass()) {
362 #define ABSTRACT_TYPE(CLASS, PARENT)
363 #define TYPE(CLASS, PARENT) case Type::CLASS: \
364  print##CLASS##After(cast<CLASS##Type>(T), OS); \
365  break;
366 #include "clang/AST/TypeNodes.inc"
367  }
368 }
369 
370 void TypePrinter::printBuiltinBefore(const BuiltinType *T, raw_ostream &OS) {
371  OS << T->getName(Policy);
372  spaceBeforePlaceHolder(OS);
373 }
374 
375 void TypePrinter::printBuiltinAfter(const BuiltinType *T, raw_ostream &OS) {}
376 
377 void TypePrinter::printComplexBefore(const ComplexType *T, raw_ostream &OS) {
378  OS << "_Complex ";
379  printBefore(T->getElementType(), OS);
380 }
381 
382 void TypePrinter::printComplexAfter(const ComplexType *T, raw_ostream &OS) {
383  printAfter(T->getElementType(), OS);
384 }
385 
386 void TypePrinter::printPointerBefore(const PointerType *T, raw_ostream &OS) {
387  IncludeStrongLifetimeRAII Strong(Policy);
388  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
389  printBefore(T->getPointeeType(), OS);
390  // Handle things like 'int (*A)[4];' correctly.
391  // FIXME: this should include vectors, but vectors use attributes I guess.
392  if (isa<ArrayType>(T->getPointeeType()))
393  OS << '(';
394  OS << '*';
395 }
396 
397 void TypePrinter::printPointerAfter(const PointerType *T, raw_ostream &OS) {
398  IncludeStrongLifetimeRAII Strong(Policy);
399  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
400  // Handle things like 'int (*A)[4];' correctly.
401  // FIXME: this should include vectors, but vectors use attributes I guess.
402  if (isa<ArrayType>(T->getPointeeType()))
403  OS << ')';
404  printAfter(T->getPointeeType(), OS);
405 }
406 
407 void TypePrinter::printBlockPointerBefore(const BlockPointerType *T,
408  raw_ostream &OS) {
409  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
410  printBefore(T->getPointeeType(), OS);
411  OS << '^';
412 }
413 
414 void TypePrinter::printBlockPointerAfter(const BlockPointerType *T,
415  raw_ostream &OS) {
416  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
417  printAfter(T->getPointeeType(), OS);
418 }
419 
420 // When printing a reference, the referenced type might also be a reference.
421 // If so, we want to skip that before printing the inner type.
423  if (auto *Ref = T->getAs<ReferenceType>())
424  return skipTopLevelReferences(Ref->getPointeeTypeAsWritten());
425  return T;
426 }
427 
428 void TypePrinter::printLValueReferenceBefore(const LValueReferenceType *T,
429  raw_ostream &OS) {
430  IncludeStrongLifetimeRAII Strong(Policy);
431  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
433  printBefore(Inner, OS);
434  // Handle things like 'int (&A)[4];' correctly.
435  // FIXME: this should include vectors, but vectors use attributes I guess.
436  if (isa<ArrayType>(Inner))
437  OS << '(';
438  OS << '&';
439 }
440 
441 void TypePrinter::printLValueReferenceAfter(const LValueReferenceType *T,
442  raw_ostream &OS) {
443  IncludeStrongLifetimeRAII Strong(Policy);
444  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
446  // Handle things like 'int (&A)[4];' correctly.
447  // FIXME: this should include vectors, but vectors use attributes I guess.
448  if (isa<ArrayType>(Inner))
449  OS << ')';
450  printAfter(Inner, OS);
451 }
452 
453 void TypePrinter::printRValueReferenceBefore(const RValueReferenceType *T,
454  raw_ostream &OS) {
455  IncludeStrongLifetimeRAII Strong(Policy);
456  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
458  printBefore(Inner, OS);
459  // Handle things like 'int (&&A)[4];' correctly.
460  // FIXME: this should include vectors, but vectors use attributes I guess.
461  if (isa<ArrayType>(Inner))
462  OS << '(';
463  OS << "&&";
464 }
465 
466 void TypePrinter::printRValueReferenceAfter(const RValueReferenceType *T,
467  raw_ostream &OS) {
468  IncludeStrongLifetimeRAII Strong(Policy);
469  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
471  // Handle things like 'int (&&A)[4];' correctly.
472  // FIXME: this should include vectors, but vectors use attributes I guess.
473  if (isa<ArrayType>(Inner))
474  OS << ')';
475  printAfter(Inner, OS);
476 }
477 
478 void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
479  raw_ostream &OS) {
480  IncludeStrongLifetimeRAII Strong(Policy);
481  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
482  printBefore(T->getPointeeType(), OS);
483  // Handle things like 'int (Cls::*A)[4];' correctly.
484  // FIXME: this should include vectors, but vectors use attributes I guess.
485  if (isa<ArrayType>(T->getPointeeType()))
486  OS << '(';
487 
488  PrintingPolicy InnerPolicy(Policy);
489  InnerPolicy.IncludeTagDefinition = false;
490  TypePrinter(InnerPolicy).print(QualType(T->getClass(), 0), OS, StringRef());
491 
492  OS << "::*";
493 }
494 
495 void TypePrinter::printMemberPointerAfter(const MemberPointerType *T,
496  raw_ostream &OS) {
497  IncludeStrongLifetimeRAII Strong(Policy);
498  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
499  // Handle things like 'int (Cls::*A)[4];' correctly.
500  // FIXME: this should include vectors, but vectors use attributes I guess.
501  if (isa<ArrayType>(T->getPointeeType()))
502  OS << ')';
503  printAfter(T->getPointeeType(), OS);
504 }
505 
506 void TypePrinter::printConstantArrayBefore(const ConstantArrayType *T,
507  raw_ostream &OS) {
508  IncludeStrongLifetimeRAII Strong(Policy);
509  printBefore(T->getElementType(), OS);
510 }
511 
512 void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T,
513  raw_ostream &OS) {
514  OS << '[';
517  Policy.Restrict);
518  OS << ' ';
519  }
520 
522  OS << "static ";
523 
524  OS << T->getSize().getZExtValue() << ']';
525  printAfter(T->getElementType(), OS);
526 }
527 
528 void TypePrinter::printIncompleteArrayBefore(const IncompleteArrayType *T,
529  raw_ostream &OS) {
530  IncludeStrongLifetimeRAII Strong(Policy);
531  printBefore(T->getElementType(), OS);
532 }
533 
534 void TypePrinter::printIncompleteArrayAfter(const IncompleteArrayType *T,
535  raw_ostream &OS) {
536  OS << "[]";
537  printAfter(T->getElementType(), OS);
538 }
539 
540 void TypePrinter::printVariableArrayBefore(const VariableArrayType *T,
541  raw_ostream &OS) {
542  IncludeStrongLifetimeRAII Strong(Policy);
543  printBefore(T->getElementType(), OS);
544 }
545 
546 void TypePrinter::printVariableArrayAfter(const VariableArrayType *T,
547  raw_ostream &OS) {
548  OS << '[';
550  AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers(), Policy.Restrict);
551  OS << ' ';
552  }
553 
555  OS << "static ";
556  else if (T->getSizeModifier() == VariableArrayType::Star)
557  OS << '*';
558 
559  if (T->getSizeExpr())
560  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
561  OS << ']';
562 
563  printAfter(T->getElementType(), OS);
564 }
565 
566 void TypePrinter::printAdjustedBefore(const AdjustedType *T, raw_ostream &OS) {
567  // Print the adjusted representation, otherwise the adjustment will be
568  // invisible.
569  printBefore(T->getAdjustedType(), OS);
570 }
571 
572 void TypePrinter::printAdjustedAfter(const AdjustedType *T, raw_ostream &OS) {
573  printAfter(T->getAdjustedType(), OS);
574 }
575 
576 void TypePrinter::printDecayedBefore(const DecayedType *T, raw_ostream &OS) {
577  // Print as though it's a pointer.
578  printAdjustedBefore(T, OS);
579 }
580 
581 void TypePrinter::printDecayedAfter(const DecayedType *T, raw_ostream &OS) {
582  printAdjustedAfter(T, OS);
583 }
584 
585 void TypePrinter::printDependentSizedArrayBefore(
586  const DependentSizedArrayType *T,
587  raw_ostream &OS) {
588  IncludeStrongLifetimeRAII Strong(Policy);
589  printBefore(T->getElementType(), OS);
590 }
591 
592 void TypePrinter::printDependentSizedArrayAfter(
593  const DependentSizedArrayType *T,
594  raw_ostream &OS) {
595  OS << '[';
596  if (T->getSizeExpr())
597  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
598  OS << ']';
599  printAfter(T->getElementType(), OS);
600 }
601 
602 void TypePrinter::printDependentAddressSpaceBefore(
603  const DependentAddressSpaceType *T, raw_ostream &OS) {
604  printBefore(T->getPointeeType(), OS);
605 }
606 
607 void TypePrinter::printDependentAddressSpaceAfter(
608  const DependentAddressSpaceType *T, raw_ostream &OS) {
609  OS << " __attribute__((address_space(";
610  if (T->getAddrSpaceExpr())
611  T->getAddrSpaceExpr()->printPretty(OS, nullptr, Policy);
612  OS << ")))";
613  printAfter(T->getPointeeType(), OS);
614 }
615 
616 void TypePrinter::printDependentSizedExtVectorBefore(
618  raw_ostream &OS) {
619  printBefore(T->getElementType(), OS);
620 }
621 
622 void TypePrinter::printDependentSizedExtVectorAfter(
624  raw_ostream &OS) {
625  OS << " __attribute__((ext_vector_type(";
626  if (T->getSizeExpr())
627  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
628  OS << ")))";
629  printAfter(T->getElementType(), OS);
630 }
631 
632 void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
633  switch (T->getVectorKind()) {
635  OS << "__vector __pixel ";
636  break;
638  OS << "__vector __bool ";
639  printBefore(T->getElementType(), OS);
640  break;
642  OS << "__vector ";
643  printBefore(T->getElementType(), OS);
644  break;
646  OS << "__attribute__((neon_vector_type("
647  << T->getNumElements() << "))) ";
648  printBefore(T->getElementType(), OS);
649  break;
651  OS << "__attribute__((neon_polyvector_type(" <<
652  T->getNumElements() << "))) ";
653  printBefore(T->getElementType(), OS);
654  break;
656  // FIXME: We prefer to print the size directly here, but have no way
657  // to get the size of the type.
658  OS << "__attribute__((__vector_size__("
659  << T->getNumElements()
660  << " * sizeof(";
661  print(T->getElementType(), OS, StringRef());
662  OS << ")))) ";
663  printBefore(T->getElementType(), OS);
664  break;
665  }
668  // FIXME: We prefer to print the size directly here, but have no way
669  // to get the size of the type.
670  OS << "__attribute__((__arm_sve_vector_bits__(";
671 
673  // Predicates take a bit per byte of the vector size, multiply by 8 to
674  // get the number of bits passed to the attribute.
675  OS << T->getNumElements() * 8;
676  else
677  OS << T->getNumElements();
678 
679  OS << " * sizeof(";
680  print(T->getElementType(), OS, StringRef());
681  // Multiply by 8 for the number of bits.
682  OS << ") * 8))) ";
683  printBefore(T->getElementType(), OS);
684  }
685 }
686 
687 void TypePrinter::printVectorAfter(const VectorType *T, raw_ostream &OS) {
688  printAfter(T->getElementType(), OS);
689 }
690 
691 void TypePrinter::printDependentVectorBefore(
692  const DependentVectorType *T, raw_ostream &OS) {
693  switch (T->getVectorKind()) {
695  OS << "__vector __pixel ";
696  break;
698  OS << "__vector __bool ";
699  printBefore(T->getElementType(), OS);
700  break;
702  OS << "__vector ";
703  printBefore(T->getElementType(), OS);
704  break;
706  OS << "__attribute__((neon_vector_type(";
707  if (T->getSizeExpr())
708  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
709  OS << "))) ";
710  printBefore(T->getElementType(), OS);
711  break;
713  OS << "__attribute__((neon_polyvector_type(";
714  if (T->getSizeExpr())
715  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
716  OS << "))) ";
717  printBefore(T->getElementType(), OS);
718  break;
720  // FIXME: We prefer to print the size directly here, but have no way
721  // to get the size of the type.
722  OS << "__attribute__((__vector_size__(";
723  if (T->getSizeExpr())
724  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
725  OS << " * sizeof(";
726  print(T->getElementType(), OS, StringRef());
727  OS << ")))) ";
728  printBefore(T->getElementType(), OS);
729  break;
730  }
733  // FIXME: We prefer to print the size directly here, but have no way
734  // to get the size of the type.
735  OS << "__attribute__((__arm_sve_vector_bits__(";
736  if (T->getSizeExpr()) {
737  T->getSizeExpr()->printPretty(OS, nullptr, Policy);
739  // Predicates take a bit per byte of the vector size, multiply by 8 to
740  // get the number of bits passed to the attribute.
741  OS << " * 8";
742  OS << " * sizeof(";
743  print(T->getElementType(), OS, StringRef());
744  // Multiply by 8 for the number of bits.
745  OS << ") * 8";
746  }
747  OS << "))) ";
748  printBefore(T->getElementType(), OS);
749  }
750 }
751 
752 void TypePrinter::printDependentVectorAfter(
753  const DependentVectorType *T, raw_ostream &OS) {
754  printAfter(T->getElementType(), OS);
755 }
756 
757 void TypePrinter::printExtVectorBefore(const ExtVectorType *T,
758  raw_ostream &OS) {
759  printBefore(T->getElementType(), OS);
760 }
761 
762 void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) {
763  printAfter(T->getElementType(), OS);
764  OS << " __attribute__((ext_vector_type(";
765  OS << T->getNumElements();
766  OS << ")))";
767 }
768 
769 void TypePrinter::printConstantMatrixBefore(const ConstantMatrixType *T,
770  raw_ostream &OS) {
771  printBefore(T->getElementType(), OS);
772  OS << " __attribute__((matrix_type(";
773  OS << T->getNumRows() << ", " << T->getNumColumns();
774  OS << ")))";
775 }
776 
777 void TypePrinter::printConstantMatrixAfter(const ConstantMatrixType *T,
778  raw_ostream &OS) {
779  printAfter(T->getElementType(), OS);
780 }
781 
782 void TypePrinter::printDependentSizedMatrixBefore(
783  const DependentSizedMatrixType *T, raw_ostream &OS) {
784  printBefore(T->getElementType(), OS);
785  OS << " __attribute__((matrix_type(";
786  if (T->getRowExpr()) {
787  T->getRowExpr()->printPretty(OS, nullptr, Policy);
788  }
789  OS << ", ";
790  if (T->getColumnExpr()) {
791  T->getColumnExpr()->printPretty(OS, nullptr, Policy);
792  }
793  OS << ")))";
794 }
795 
796 void TypePrinter::printDependentSizedMatrixAfter(
797  const DependentSizedMatrixType *T, raw_ostream &OS) {
798  printAfter(T->getElementType(), OS);
799 }
800 
801 void
803  const PrintingPolicy &Policy)
804  const {
805  if (hasDynamicExceptionSpec()) {
806  OS << " throw(";
808  OS << "...";
809  else
810  for (unsigned I = 0, N = getNumExceptions(); I != N; ++I) {
811  if (I)
812  OS << ", ";
813 
814  OS << getExceptionType(I).stream(Policy);
815  }
816  OS << ')';
817  } else if (EST_NoThrow == getExceptionSpecType()) {
818  OS << " __attribute__((nothrow))";
820  OS << " noexcept";
821  // FIXME:Is it useful to print out the expression for a non-dependent
822  // noexcept specification?
824  OS << '(';
825  if (getNoexceptExpr())
826  getNoexceptExpr()->printPretty(OS, nullptr, Policy);
827  OS << ')';
828  }
829  }
830 }
831 
832 void TypePrinter::printFunctionProtoBefore(const FunctionProtoType *T,
833  raw_ostream &OS) {
834  if (T->hasTrailingReturn()) {
835  OS << "auto ";
836  if (!HasEmptyPlaceHolder)
837  OS << '(';
838  } else {
839  // If needed for precedence reasons, wrap the inner part in grouping parens.
840  SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder, false);
841  printBefore(T->getReturnType(), OS);
842  if (!PrevPHIsEmpty.get())
843  OS << '(';
844  }
845 }
846 
848  switch (ABI) {
850  llvm_unreachable("asking for spelling of ordinary parameter ABI");
852  return "swift_context";
854  return "swift_async_context";
856  return "swift_error_result";
858  return "swift_indirect_result";
859  }
860  llvm_unreachable("bad parameter ABI kind");
861 }
862 
863 void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
864  raw_ostream &OS) {
865  // If needed for precedence reasons, wrap the inner part in grouping parens.
866  if (!HasEmptyPlaceHolder)
867  OS << ')';
868  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
869 
870  OS << '(';
871  {
872  ParamPolicyRAII ParamPolicy(Policy);
873  for (unsigned i = 0, e = T->getNumParams(); i != e; ++i) {
874  if (i) OS << ", ";
875 
876  auto EPI = T->getExtParameterInfo(i);
877  if (EPI.isConsumed()) OS << "__attribute__((ns_consumed)) ";
878  if (EPI.isNoEscape())
879  OS << "__attribute__((noescape)) ";
880  auto ABI = EPI.getABI();
881  if (ABI != ParameterABI::Ordinary)
882  OS << "__attribute__((" << getParameterABISpelling(ABI) << ")) ";
883 
884  print(T->getParamType(i), OS, StringRef());
885  }
886  }
887 
888  if (T->isVariadic()) {
889  if (T->getNumParams())
890  OS << ", ";
891  OS << "...";
892  } else if (T->getNumParams() == 0 && Policy.UseVoidForZeroParams) {
893  // Do not emit int() if we have a proto, emit 'int(void)'.
894  OS << "void";
895  }
896 
897  OS << ')';
898 
899  FunctionType::ExtInfo Info = T->getExtInfo();
900 
901  printFunctionAfter(Info, OS);
902 
903  if (!T->getMethodQuals().empty())
904  OS << " " << T->getMethodQuals().getAsString();
905 
906  switch (T->getRefQualifier()) {
907  case RQ_None:
908  break;
909 
910  case RQ_LValue:
911  OS << " &";
912  break;
913 
914  case RQ_RValue:
915  OS << " &&";
916  break;
917  }
918  T->printExceptionSpecification(OS, Policy);
919 
920  if (T->hasTrailingReturn()) {
921  OS << " -> ";
922  print(T->getReturnType(), OS, StringRef());
923  } else
924  printAfter(T->getReturnType(), OS);
925 }
926 
927 void TypePrinter::printFunctionAfter(const FunctionType::ExtInfo &Info,
928  raw_ostream &OS) {
929  if (!InsideCCAttribute) {
930  switch (Info.getCC()) {
931  case CC_C:
932  // The C calling convention is the default on the vast majority of platforms
933  // we support. If the user wrote it explicitly, it will usually be printed
934  // while traversing the AttributedType. If the type has been desugared, let
935  // the canonical spelling be the implicit calling convention.
936  // FIXME: It would be better to be explicit in certain contexts, such as a
937  // cdecl function typedef used to declare a member function with the
938  // Microsoft C++ ABI.
939  break;
940  case CC_X86StdCall:
941  OS << " __attribute__((stdcall))";
942  break;
943  case CC_X86FastCall:
944  OS << " __attribute__((fastcall))";
945  break;
946  case CC_X86ThisCall:
947  OS << " __attribute__((thiscall))";
948  break;
949  case CC_X86VectorCall:
950  OS << " __attribute__((vectorcall))";
951  break;
952  case CC_X86Pascal:
953  OS << " __attribute__((pascal))";
954  break;
955  case CC_AAPCS:
956  OS << " __attribute__((pcs(\"aapcs\")))";
957  break;
958  case CC_AAPCS_VFP:
959  OS << " __attribute__((pcs(\"aapcs-vfp\")))";
960  break;
962  OS << "__attribute__((aarch64_vector_pcs))";
963  break;
964  case CC_AArch64SVEPCS:
965  OS << "__attribute__((aarch64_sve_pcs))";
966  break;
967  case CC_AMDGPUKernelCall:
968  OS << "__attribute__((amdgpu_kernel))";
969  break;
970  case CC_IntelOclBicc:
971  OS << " __attribute__((intel_ocl_bicc))";
972  break;
973  case CC_Win64:
974  OS << " __attribute__((ms_abi))";
975  break;
976  case CC_X86_64SysV:
977  OS << " __attribute__((sysv_abi))";
978  break;
979  case CC_X86RegCall:
980  OS << " __attribute__((regcall))";
981  break;
982  case CC_SpirFunction:
983  case CC_OpenCLKernel:
984  // Do nothing. These CCs are not available as attributes.
985  break;
986  case CC_Swift:
987  OS << " __attribute__((swiftcall))";
988  break;
989  case CC_SwiftAsync:
990  OS << "__attribute__((swiftasynccall))";
991  break;
992  case CC_PreserveMost:
993  OS << " __attribute__((preserve_most))";
994  break;
995  case CC_PreserveAll:
996  OS << " __attribute__((preserve_all))";
997  break;
998  }
999  }
1000 
1001  if (Info.getNoReturn())
1002  OS << " __attribute__((noreturn))";
1003  if (Info.getCmseNSCall())
1004  OS << " __attribute__((cmse_nonsecure_call))";
1005  if (Info.getProducesResult())
1006  OS << " __attribute__((ns_returns_retained))";
1007  if (Info.getRegParm())
1008  OS << " __attribute__((regparm ("
1009  << Info.getRegParm() << ")))";
1010  if (Info.getNoCallerSavedRegs())
1011  OS << " __attribute__((no_caller_saved_registers))";
1012  if (Info.getNoCfCheck())
1013  OS << " __attribute__((nocf_check))";
1014 }
1015 
1016 void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T,
1017  raw_ostream &OS) {
1018  // If needed for precedence reasons, wrap the inner part in grouping parens.
1019  SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder, false);
1020  printBefore(T->getReturnType(), OS);
1021  if (!PrevPHIsEmpty.get())
1022  OS << '(';
1023 }
1024 
1025 void TypePrinter::printFunctionNoProtoAfter(const FunctionNoProtoType *T,
1026  raw_ostream &OS) {
1027  // If needed for precedence reasons, wrap the inner part in grouping parens.
1028  if (!HasEmptyPlaceHolder)
1029  OS << ')';
1030  SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
1031 
1032  OS << "()";
1033  printFunctionAfter(T->getExtInfo(), OS);
1034  printAfter(T->getReturnType(), OS);
1035 }
1036 
1037 void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) {
1038 
1039  // Compute the full nested-name-specifier for this type.
1040  // In C, this will always be empty except when the type
1041  // being printed is anonymous within other Record.
1042  if (!Policy.SuppressScope)
1043  AppendScope(D->getDeclContext(), OS, D->getDeclName());
1044 
1045  IdentifierInfo *II = D->getIdentifier();
1046  OS << II->getName();
1047  spaceBeforePlaceHolder(OS);
1048 }
1049 
1050 void TypePrinter::printUnresolvedUsingBefore(const UnresolvedUsingType *T,
1051  raw_ostream &OS) {
1052  printTypeSpec(T->getDecl(), OS);
1053 }
1054 
1055 void TypePrinter::printUnresolvedUsingAfter(const UnresolvedUsingType *T,
1056  raw_ostream &OS) {}
1057 
1058 void TypePrinter::printUsingBefore(const UsingType *T, raw_ostream &OS) {
1059  // After `namespace b { using a::X }`, is the type X within B a::X or b::X?
1060  //
1061  // - b::X is more formally correct given the UsingType model
1062  // - b::X makes sense if "re-exporting" a symbol in a new namespace
1063  // - a::X makes sense if "importing" a symbol for convenience
1064  //
1065  // The "importing" use seems much more common, so we print a::X.
1066  // This could be a policy option, but the right choice seems to rest more
1067  // with the intent of the code than the caller.
1068  printTypeSpec(T->getFoundDecl()->getUnderlyingDecl(), OS);
1069 }
1070 
1071 void TypePrinter::printUsingAfter(const UsingType *T, raw_ostream &OS) {}
1072 
1073 void TypePrinter::printTypedefBefore(const TypedefType *T, raw_ostream &OS) {
1074  printTypeSpec(T->getDecl(), OS);
1075 }
1076 
1077 void TypePrinter::printMacroQualifiedBefore(const MacroQualifiedType *T,
1078  raw_ostream &OS) {
1079  StringRef MacroName = T->getMacroIdentifier()->getName();
1080  OS << MacroName << " ";
1081 
1082  // Since this type is meant to print the macro instead of the whole attribute,
1083  // we trim any attributes and go directly to the original modified type.
1084  printBefore(T->getModifiedType(), OS);
1085 }
1086 
1087 void TypePrinter::printMacroQualifiedAfter(const MacroQualifiedType *T,
1088  raw_ostream &OS) {
1089  printAfter(T->getModifiedType(), OS);
1090 }
1091 
1092 void TypePrinter::printTypedefAfter(const TypedefType *T, raw_ostream &OS) {}
1093 
1094 void TypePrinter::printTypeOfExprBefore(const TypeOfExprType *T,
1095  raw_ostream &OS) {
1096  OS << "typeof ";
1097  if (T->getUnderlyingExpr())
1098  T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy);
1099  spaceBeforePlaceHolder(OS);
1100 }
1101 
1102 void TypePrinter::printTypeOfExprAfter(const TypeOfExprType *T,
1103  raw_ostream &OS) {}
1104 
1105 void TypePrinter::printTypeOfBefore(const TypeOfType *T, raw_ostream &OS) {
1106  OS << "typeof(";
1107  print(T->getUnderlyingType(), OS, StringRef());
1108  OS << ')';
1109  spaceBeforePlaceHolder(OS);
1110 }
1111 
1112 void TypePrinter::printTypeOfAfter(const TypeOfType *T, raw_ostream &OS) {}
1113 
1114 void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) {
1115  OS << "decltype(";
1116  if (T->getUnderlyingExpr())
1117  T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy);
1118  OS << ')';
1119  spaceBeforePlaceHolder(OS);
1120 }
1121 
1122 void TypePrinter::printDecltypeAfter(const DecltypeType *T, raw_ostream &OS) {}
1123 
1124 void TypePrinter::printUnaryTransformBefore(const UnaryTransformType *T,
1125  raw_ostream &OS) {
1126  IncludeStrongLifetimeRAII Strong(Policy);
1127 
1128  switch (T->getUTTKind()) {
1130  OS << "__underlying_type(";
1131  print(T->getBaseType(), OS, StringRef());
1132  OS << ')';
1133  spaceBeforePlaceHolder(OS);
1134  return;
1135  }
1136 
1137  printBefore(T->getBaseType(), OS);
1138 }
1139 
1140 void TypePrinter::printUnaryTransformAfter(const UnaryTransformType *T,
1141  raw_ostream &OS) {
1142  IncludeStrongLifetimeRAII Strong(Policy);
1143 
1144  switch (T->getUTTKind()) {
1146  return;
1147  }
1148 
1149  printAfter(T->getBaseType(), OS);
1150 }
1151 
1152 void TypePrinter::printAutoBefore(const AutoType *T, raw_ostream &OS) {
1153  // If the type has been deduced, do not print 'auto'.
1154  if (!T->getDeducedType().isNull()) {
1155  printBefore(T->getDeducedType(), OS);
1156  } else {
1157  if (T->isConstrained()) {
1158  // FIXME: Track a TypeConstraint as type sugar, so that we can print the
1159  // type as it was written.
1160  T->getTypeConstraintConcept()->getDeclName().print(OS, Policy);
1161  auto Args = T->getTypeConstraintArguments();
1162  if (!Args.empty())
1164  OS, Args, Policy,
1166  OS << ' ';
1167  }
1168  switch (T->getKeyword()) {
1169  case AutoTypeKeyword::Auto: OS << "auto"; break;
1170  case AutoTypeKeyword::DecltypeAuto: OS << "decltype(auto)"; break;
1171  case AutoTypeKeyword::GNUAutoType: OS << "__auto_type"; break;
1172  }
1173  spaceBeforePlaceHolder(OS);
1174  }
1175 }
1176 
1177 void TypePrinter::printAutoAfter(const AutoType *T, raw_ostream &OS) {
1178  // If the type has been deduced, do not print 'auto'.
1179  if (!T->getDeducedType().isNull())
1180  printAfter(T->getDeducedType(), OS);
1181 }
1182 
1183 void TypePrinter::printDeducedTemplateSpecializationBefore(
1184  const DeducedTemplateSpecializationType *T, raw_ostream &OS) {
1185  // If the type has been deduced, print the deduced type.
1186  if (!T->getDeducedType().isNull()) {
1187  printBefore(T->getDeducedType(), OS);
1188  } else {
1189  IncludeStrongLifetimeRAII Strong(Policy);
1190  T->getTemplateName().print(OS, Policy);
1191  spaceBeforePlaceHolder(OS);
1192  }
1193 }
1194 
1195 void TypePrinter::printDeducedTemplateSpecializationAfter(
1196  const DeducedTemplateSpecializationType *T, raw_ostream &OS) {
1197  // If the type has been deduced, print the deduced type.
1198  if (!T->getDeducedType().isNull())
1199  printAfter(T->getDeducedType(), OS);
1200 }
1201 
1202 void TypePrinter::printAtomicBefore(const AtomicType *T, raw_ostream &OS) {
1203  IncludeStrongLifetimeRAII Strong(Policy);
1204 
1205  OS << "_Atomic(";
1206  print(T->getValueType(), OS, StringRef());
1207  OS << ')';
1208  spaceBeforePlaceHolder(OS);
1209 }
1210 
1211 void TypePrinter::printAtomicAfter(const AtomicType *T, raw_ostream &OS) {}
1212 
1213 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream &OS) {
1214  IncludeStrongLifetimeRAII Strong(Policy);
1215 
1216  if (T->isReadOnly())
1217  OS << "read_only ";
1218  else
1219  OS << "write_only ";
1220  OS << "pipe ";
1221  print(T->getElementType(), OS, StringRef());
1222  spaceBeforePlaceHolder(OS);
1223 }
1224 
1225 void TypePrinter::printPipeAfter(const PipeType *T, raw_ostream &OS) {}
1226 
1227 void TypePrinter::printBitIntBefore(const BitIntType *T, raw_ostream &OS) {
1228  if (T->isUnsigned())
1229  OS << "unsigned ";
1230  OS << "_BitInt(" << T->getNumBits() << ")";
1231  spaceBeforePlaceHolder(OS);
1232 }
1233 
1234 void TypePrinter::printBitIntAfter(const BitIntType *T, raw_ostream &OS) {}
1235 
1236 void TypePrinter::printDependentBitIntBefore(const DependentBitIntType *T,
1237  raw_ostream &OS) {
1238  if (T->isUnsigned())
1239  OS << "unsigned ";
1240  OS << "_BitInt(";
1241  T->getNumBitsExpr()->printPretty(OS, nullptr, Policy);
1242  OS << ")";
1243  spaceBeforePlaceHolder(OS);
1244 }
1245 
1246 void TypePrinter::printDependentBitIntAfter(const DependentBitIntType *T,
1247  raw_ostream &OS) {}
1248 
1249 /// Appends the given scope to the end of a string.
1250 void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS,
1251  DeclarationName NameInScope) {
1252  if (DC->isTranslationUnit())
1253  return;
1254 
1255  // FIXME: Consider replacing this with NamedDecl::printNestedNameSpecifier,
1256  // which can also print names for function and method scopes.
1257  if (DC->isFunctionOrMethod())
1258  return;
1259 
1260  if (Policy.Callbacks && Policy.Callbacks->isScopeVisible(DC))
1261  return;
1262 
1263  if (const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
1264  if (Policy.SuppressUnwrittenScope && NS->isAnonymousNamespace())
1265  return AppendScope(DC->getParent(), OS, NameInScope);
1266 
1267  // Only suppress an inline namespace if the name has the same lookup
1268  // results in the enclosing namespace.
1269  if (Policy.SuppressInlineNamespace && NS->isInline() && NameInScope &&
1270  NS->isRedundantInlineQualifierFor(NameInScope))
1271  return AppendScope(DC->getParent(), OS, NameInScope);
1272 
1273  AppendScope(DC->getParent(), OS, NS->getDeclName());
1274  if (NS->getIdentifier())
1275  OS << NS->getName() << "::";
1276  else
1277  OS << "(anonymous namespace)::";
1278  } else if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1279  AppendScope(DC->getParent(), OS, Spec->getDeclName());
1280  IncludeStrongLifetimeRAII Strong(Policy);
1281  OS << Spec->getIdentifier()->getName();
1282  const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
1284  OS, TemplateArgs.asArray(), Policy,
1285  Spec->getSpecializedTemplate()->getTemplateParameters());
1286  OS << "::";
1287  } else if (const auto *Tag = dyn_cast<TagDecl>(DC)) {
1288  AppendScope(DC->getParent(), OS, Tag->getDeclName());
1289  if (TypedefNameDecl *Typedef = Tag->getTypedefNameForAnonDecl())
1290  OS << Typedef->getIdentifier()->getName() << "::";
1291  else if (Tag->getIdentifier())
1292  OS << Tag->getIdentifier()->getName() << "::";
1293  else
1294  return;
1295  } else {
1296  AppendScope(DC->getParent(), OS, NameInScope);
1297  }
1298 }
1299 
1300 void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
1301  if (Policy.IncludeTagDefinition) {
1302  PrintingPolicy SubPolicy = Policy;
1303  SubPolicy.IncludeTagDefinition = false;
1304  D->print(OS, SubPolicy, Indentation);
1305  spaceBeforePlaceHolder(OS);
1306  return;
1307  }
1308 
1309  bool HasKindDecoration = false;
1310 
1311  // We don't print tags unless this is an elaborated type.
1312  // In C, we just assume every RecordType is an elaborated type.
1313  if (!Policy.SuppressTagKeyword && !D->getTypedefNameForAnonDecl()) {
1314  HasKindDecoration = true;
1315  OS << D->getKindName();
1316  OS << ' ';
1317  }
1318 
1319  // Compute the full nested-name-specifier for this type.
1320  // In C, this will always be empty except when the type
1321  // being printed is anonymous within other Record.
1322  if (!Policy.SuppressScope)
1323  AppendScope(D->getDeclContext(), OS, D->getDeclName());
1324 
1325  if (const IdentifierInfo *II = D->getIdentifier())
1326  OS << II->getName();
1327  else if (TypedefNameDecl *Typedef = D->getTypedefNameForAnonDecl()) {
1328  assert(Typedef->getIdentifier() && "Typedef without identifier?");
1329  OS << Typedef->getIdentifier()->getName();
1330  } else {
1331  // Make an unambiguous representation for anonymous types, e.g.
1332  // (anonymous enum at /usr/include/string.h:120:9)
1333  OS << (Policy.MSVCFormatting ? '`' : '(');
1334 
1335  if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) {
1336  OS << "lambda";
1337  HasKindDecoration = true;
1338  } else if ((isa<RecordDecl>(D) && cast<RecordDecl>(D)->isAnonymousStructOrUnion())) {
1339  OS << "anonymous";
1340  } else {
1341  OS << "unnamed";
1342  }
1343 
1344  if (Policy.AnonymousTagLocations) {
1345  // Suppress the redundant tag keyword if we just printed one.
1346  // We don't have to worry about ElaboratedTypes here because you can't
1347  // refer to an anonymous type with one.
1348  if (!HasKindDecoration)
1349  OS << " " << D->getKindName();
1350 
1352  D->getLocation());
1353  if (PLoc.isValid()) {
1354  OS << " at ";
1355  StringRef File = PLoc.getFilename();
1356  if (auto *Callbacks = Policy.Callbacks)
1357  OS << Callbacks->remapPath(File);
1358  else
1359  OS << File;
1360  OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
1361  }
1362  }
1363 
1364  OS << (Policy.MSVCFormatting ? '\'' : ')');
1365  }
1366 
1367  // If this is a class template specialization, print the template
1368  // arguments.
1369  if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1371  TypeSourceInfo *TAW = Spec->getTypeAsWritten();
1372  if (!Policy.PrintCanonicalTypes && TAW) {
1373  const TemplateSpecializationType *TST =
1374  cast<TemplateSpecializationType>(TAW->getType());
1375  Args = TST->template_arguments();
1376  } else {
1377  const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
1378  Args = TemplateArgs.asArray();
1379  }
1380  IncludeStrongLifetimeRAII Strong(Policy);
1382  OS, Args, Policy,
1383  Spec->getSpecializedTemplate()->getTemplateParameters());
1384  }
1385 
1386  spaceBeforePlaceHolder(OS);
1387 }
1388 
1389 void TypePrinter::printRecordBefore(const RecordType *T, raw_ostream &OS) {
1390  // Print the preferred name if we have one for this type.
1391  if (Policy.UsePreferredNames) {
1392  for (const auto *PNA : T->getDecl()->specific_attrs<PreferredNameAttr>()) {
1393  if (!declaresSameEntity(PNA->getTypedefType()->getAsCXXRecordDecl(),
1394  T->getDecl()))
1395  continue;
1396  // Find the outermost typedef or alias template.
1397  QualType T = PNA->getTypedefType();
1398  while (true) {
1399  if (auto *TT = dyn_cast<TypedefType>(T))
1400  return printTypeSpec(TT->getDecl(), OS);
1401  if (auto *TST = dyn_cast<TemplateSpecializationType>(T))
1402  return printTemplateId(TST, OS, /*FullyQualify=*/true);
1404  }
1405  }
1406  }
1407 
1408  printTag(T->getDecl(), OS);
1409 }
1410 
1411 void TypePrinter::printRecordAfter(const RecordType *T, raw_ostream &OS) {}
1412 
1413 void TypePrinter::printEnumBefore(const EnumType *T, raw_ostream &OS) {
1414  printTag(T->getDecl(), OS);
1415 }
1416 
1417 void TypePrinter::printEnumAfter(const EnumType *T, raw_ostream &OS) {}
1418 
1419 void TypePrinter::printTemplateTypeParmBefore(const TemplateTypeParmType *T,
1420  raw_ostream &OS) {
1421  TemplateTypeParmDecl *D = T->getDecl();
1422  if (D && D->isImplicit()) {
1423  if (auto *TC = D->getTypeConstraint()) {
1424  TC->print(OS, Policy);
1425  OS << ' ';
1426  }
1427  OS << "auto";
1428  } else if (IdentifierInfo *Id = T->getIdentifier())
1429  OS << (Policy.CleanUglifiedParameters ? Id->deuglifiedName()
1430  : Id->getName());
1431  else
1432  OS << "type-parameter-" << T->getDepth() << '-' << T->getIndex();
1433 
1434  spaceBeforePlaceHolder(OS);
1435 }
1436 
1437 void TypePrinter::printTemplateTypeParmAfter(const TemplateTypeParmType *T,
1438  raw_ostream &OS) {}
1439 
1440 void TypePrinter::printSubstTemplateTypeParmBefore(
1441  const SubstTemplateTypeParmType *T,
1442  raw_ostream &OS) {
1443  IncludeStrongLifetimeRAII Strong(Policy);
1444  printBefore(T->getReplacementType(), OS);
1445 }
1446 
1447 void TypePrinter::printSubstTemplateTypeParmAfter(
1448  const SubstTemplateTypeParmType *T,
1449  raw_ostream &OS) {
1450  IncludeStrongLifetimeRAII Strong(Policy);
1451  printAfter(T->getReplacementType(), OS);
1452 }
1453 
1454 void TypePrinter::printSubstTemplateTypeParmPackBefore(
1456  raw_ostream &OS) {
1457  IncludeStrongLifetimeRAII Strong(Policy);
1458  printTemplateTypeParmBefore(T->getReplacedParameter(), OS);
1459 }
1460 
1461 void TypePrinter::printSubstTemplateTypeParmPackAfter(
1463  raw_ostream &OS) {
1464  IncludeStrongLifetimeRAII Strong(Policy);
1465  printTemplateTypeParmAfter(T->getReplacedParameter(), OS);
1466 }
1467 
1468 void TypePrinter::printTemplateId(const TemplateSpecializationType *T,
1469  raw_ostream &OS, bool FullyQualify) {
1470  IncludeStrongLifetimeRAII Strong(Policy);
1471 
1473  if (FullyQualify && TD) {
1474  if (!Policy.SuppressScope)
1475  AppendScope(TD->getDeclContext(), OS, TD->getDeclName());
1476 
1477  OS << TD->getName();
1478  } else {
1479  T->getTemplateName().print(OS, Policy);
1480  }
1481 
1483  spaceBeforePlaceHolder(OS);
1484 }
1485 
1486 void TypePrinter::printTemplateSpecializationBefore(
1487  const TemplateSpecializationType *T,
1488  raw_ostream &OS) {
1489  printTemplateId(T, OS, Policy.FullyQualifiedName);
1490 }
1491 
1492 void TypePrinter::printTemplateSpecializationAfter(
1493  const TemplateSpecializationType *T,
1494  raw_ostream &OS) {}
1495 
1496 void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
1497  raw_ostream &OS) {
1498  if (Policy.PrintInjectedClassNameWithArguments)
1499  return printTemplateSpecializationBefore(T->getInjectedTST(), OS);
1500 
1501  IncludeStrongLifetimeRAII Strong(Policy);
1502  T->getTemplateName().print(OS, Policy);
1503  spaceBeforePlaceHolder(OS);
1504 }
1505 
1506 void TypePrinter::printInjectedClassNameAfter(const InjectedClassNameType *T,
1507  raw_ostream &OS) {}
1508 
1509 void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
1510  raw_ostream &OS) {
1511  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl()) {
1512  TagDecl *OwnedTagDecl = T->getOwnedTagDecl();
1513  assert(OwnedTagDecl->getTypeForDecl() == T->getNamedType().getTypePtr() &&
1514  "OwnedTagDecl expected to be a declaration for the type");
1515  PrintingPolicy SubPolicy = Policy;
1516  SubPolicy.IncludeTagDefinition = false;
1517  OwnedTagDecl->print(OS, SubPolicy, Indentation);
1518  spaceBeforePlaceHolder(OS);
1519  return;
1520  }
1521 
1522  // The tag definition will take care of these.
1523  if (!Policy.IncludeTagDefinition)
1524  {
1526  if (T->getKeyword() != ETK_None)
1527  OS << " ";
1529  if (Qualifier)
1530  Qualifier->print(OS, Policy);
1531  }
1532 
1533  ElaboratedTypePolicyRAII PolicyRAII(Policy);
1534  printBefore(T->getNamedType(), OS);
1535 }
1536 
1537 void TypePrinter::printElaboratedAfter(const ElaboratedType *T,
1538  raw_ostream &OS) {
1539  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl())
1540  return;
1541  ElaboratedTypePolicyRAII PolicyRAII(Policy);
1542  printAfter(T->getNamedType(), OS);
1543 }
1544 
1545 void TypePrinter::printParenBefore(const ParenType *T, raw_ostream &OS) {
1546  if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->getInnerType())) {
1547  printBefore(T->getInnerType(), OS);
1548  OS << '(';
1549  } else
1550  printBefore(T->getInnerType(), OS);
1551 }
1552 
1553 void TypePrinter::printParenAfter(const ParenType *T, raw_ostream &OS) {
1554  if (!HasEmptyPlaceHolder && !isa<FunctionType>(T->getInnerType())) {
1555  OS << ')';
1556  printAfter(T->getInnerType(), OS);
1557  } else
1558  printAfter(T->getInnerType(), OS);
1559 }
1560 
1561 void TypePrinter::printDependentNameBefore(const DependentNameType *T,
1562  raw_ostream &OS) {
1564  if (T->getKeyword() != ETK_None)
1565  OS << " ";
1566 
1567  T->getQualifier()->print(OS, Policy);
1568 
1569  OS << T->getIdentifier()->getName();
1570  spaceBeforePlaceHolder(OS);
1571 }
1572 
1573 void TypePrinter::printDependentNameAfter(const DependentNameType *T,
1574  raw_ostream &OS) {}
1575 
1576 void TypePrinter::printDependentTemplateSpecializationBefore(
1577  const DependentTemplateSpecializationType *T, raw_ostream &OS) {
1578  IncludeStrongLifetimeRAII Strong(Policy);
1579 
1581  if (T->getKeyword() != ETK_None)
1582  OS << " ";
1583 
1584  if (T->getQualifier())
1585  T->getQualifier()->print(OS, Policy);
1586  OS << "template " << T->getIdentifier()->getName();
1588  spaceBeforePlaceHolder(OS);
1589 }
1590 
1591 void TypePrinter::printDependentTemplateSpecializationAfter(
1592  const DependentTemplateSpecializationType *T, raw_ostream &OS) {}
1593 
1594 void TypePrinter::printPackExpansionBefore(const PackExpansionType *T,
1595  raw_ostream &OS) {
1596  printBefore(T->getPattern(), OS);
1597 }
1598 
1599 void TypePrinter::printPackExpansionAfter(const PackExpansionType *T,
1600  raw_ostream &OS) {
1601  printAfter(T->getPattern(), OS);
1602  OS << "...";
1603 }
1604 
1605 void TypePrinter::printAttributedBefore(const AttributedType *T,
1606  raw_ostream &OS) {
1607  // FIXME: Generate this with TableGen.
1608 
1609  // Prefer the macro forms of the GC and ownership qualifiers.
1610  if (T->getAttrKind() == attr::ObjCGC ||
1611  T->getAttrKind() == attr::ObjCOwnership)
1612  return printBefore(T->getEquivalentType(), OS);
1613 
1614  if (T->getAttrKind() == attr::ObjCKindOf)
1615  OS << "__kindof ";
1616 
1617  if (T->getAttrKind() == attr::AddressSpace)
1618  printBefore(T->getEquivalentType(), OS);
1619  else
1620  printBefore(T->getModifiedType(), OS);
1621 
1622  if (T->isMSTypeSpec()) {
1623  switch (T->getAttrKind()) {
1624  default: return;
1625  case attr::Ptr32: OS << " __ptr32"; break;
1626  case attr::Ptr64: OS << " __ptr64"; break;
1627  case attr::SPtr: OS << " __sptr"; break;
1628  case attr::UPtr: OS << " __uptr"; break;
1629  }
1630  spaceBeforePlaceHolder(OS);
1631  }
1632 
1633  // Print nullability type specifiers.
1634  if (T->getImmediateNullability()) {
1635  if (T->getAttrKind() == attr::TypeNonNull)
1636  OS << " _Nonnull";
1637  else if (T->getAttrKind() == attr::TypeNullable)
1638  OS << " _Nullable";
1639  else if (T->getAttrKind() == attr::TypeNullUnspecified)
1640  OS << " _Null_unspecified";
1641  else if (T->getAttrKind() == attr::TypeNullableResult)
1642  OS << " _Nullable_result";
1643  else
1644  llvm_unreachable("unhandled nullability");
1645  spaceBeforePlaceHolder(OS);
1646  }
1647 }
1648 
1649 void TypePrinter::printAttributedAfter(const AttributedType *T,
1650  raw_ostream &OS) {
1651  // FIXME: Generate this with TableGen.
1652 
1653  // Prefer the macro forms of the GC and ownership qualifiers.
1654  if (T->getAttrKind() == attr::ObjCGC ||
1655  T->getAttrKind() == attr::ObjCOwnership)
1656  return printAfter(T->getEquivalentType(), OS);
1657 
1658  // If this is a calling convention attribute, don't print the implicit CC from
1659  // the modified type.
1660  SaveAndRestore<bool> MaybeSuppressCC(InsideCCAttribute, T->isCallingConv());
1661 
1662  printAfter(T->getModifiedType(), OS);
1663 
1664  // Some attributes are printed as qualifiers before the type, so we have
1665  // nothing left to do.
1666  if (T->getAttrKind() == attr::ObjCKindOf ||
1668  return;
1669 
1670  // Don't print the inert __unsafe_unretained attribute at all.
1671  if (T->getAttrKind() == attr::ObjCInertUnsafeUnretained)
1672  return;
1673 
1674  // Don't print ns_returns_retained unless it had an effect.
1675  if (T->getAttrKind() == attr::NSReturnsRetained &&
1678  return;
1679 
1680  if (T->getAttrKind() == attr::LifetimeBound) {
1681  OS << " [[clang::lifetimebound]]";
1682  return;
1683  }
1684 
1685  // The printing of the address_space attribute is handled by the qualifier
1686  // since it is still stored in the qualifier. Return early to prevent printing
1687  // this twice.
1688  if (T->getAttrKind() == attr::AddressSpace)
1689  return;
1690 
1691  OS << " __attribute__((";
1692  switch (T->getAttrKind()) {
1693 #define TYPE_ATTR(NAME)
1694 #define DECL_OR_TYPE_ATTR(NAME)
1695 #define ATTR(NAME) case attr::NAME:
1696 #include "clang/Basic/AttrList.inc"
1697  llvm_unreachable("non-type attribute attached to type");
1698 
1699  case attr::BTFTypeTag:
1700  llvm_unreachable("BTFTypeTag attribute handled separately");
1701 
1702  case attr::OpenCLPrivateAddressSpace:
1703  case attr::OpenCLGlobalAddressSpace:
1704  case attr::OpenCLGlobalDeviceAddressSpace:
1705  case attr::OpenCLGlobalHostAddressSpace:
1706  case attr::OpenCLLocalAddressSpace:
1707  case attr::OpenCLConstantAddressSpace:
1708  case attr::OpenCLGenericAddressSpace:
1709  // FIXME: Update printAttributedBefore to print these once we generate
1710  // AttributedType nodes for them.
1711  break;
1712 
1713  case attr::LifetimeBound:
1714  case attr::TypeNonNull:
1715  case attr::TypeNullable:
1716  case attr::TypeNullableResult:
1717  case attr::TypeNullUnspecified:
1718  case attr::ObjCGC:
1719  case attr::ObjCInertUnsafeUnretained:
1720  case attr::ObjCKindOf:
1721  case attr::ObjCOwnership:
1722  case attr::Ptr32:
1723  case attr::Ptr64:
1724  case attr::SPtr:
1725  case attr::UPtr:
1726  case attr::AddressSpace:
1727  case attr::CmseNSCall:
1728  llvm_unreachable("This attribute should have been handled already");
1729 
1730  case attr::NSReturnsRetained:
1731  OS << "ns_returns_retained";
1732  break;
1733 
1734  // FIXME: When Sema learns to form this AttributedType, avoid printing the
1735  // attribute again in printFunctionProtoAfter.
1736  case attr::AnyX86NoCfCheck: OS << "nocf_check"; break;
1737  case attr::CDecl: OS << "cdecl"; break;
1738  case attr::FastCall: OS << "fastcall"; break;
1739  case attr::StdCall: OS << "stdcall"; break;
1740  case attr::ThisCall: OS << "thiscall"; break;
1741  case attr::SwiftCall: OS << "swiftcall"; break;
1742  case attr::SwiftAsyncCall: OS << "swiftasynccall"; break;
1743  case attr::VectorCall: OS << "vectorcall"; break;
1744  case attr::Pascal: OS << "pascal"; break;
1745  case attr::MSABI: OS << "ms_abi"; break;
1746  case attr::SysVABI: OS << "sysv_abi"; break;
1747  case attr::RegCall: OS << "regcall"; break;
1748  case attr::Pcs: {
1749  OS << "pcs(";
1750  QualType t = T->getEquivalentType();
1751  while (!t->isFunctionType())
1752  t = t->getPointeeType();
1753  OS << (t->castAs<FunctionType>()->getCallConv() == CC_AAPCS ?
1754  "\"aapcs\"" : "\"aapcs-vfp\"");
1755  OS << ')';
1756  break;
1757  }
1758  case attr::AArch64VectorPcs: OS << "aarch64_vector_pcs"; break;
1759  case attr::AArch64SVEPcs: OS << "aarch64_sve_pcs"; break;
1760  case attr::AMDGPUKernelCall: OS << "amdgpu_kernel"; break;
1761  case attr::IntelOclBicc: OS << "inteloclbicc"; break;
1762  case attr::PreserveMost:
1763  OS << "preserve_most";
1764  break;
1765 
1766  case attr::PreserveAll:
1767  OS << "preserve_all";
1768  break;
1769  case attr::NoDeref:
1770  OS << "noderef";
1771  break;
1772  case attr::AcquireHandle:
1773  OS << "acquire_handle";
1774  break;
1775  case attr::ArmMveStrictPolymorphism:
1776  OS << "__clang_arm_mve_strict_polymorphism";
1777  break;
1778  }
1779  OS << "))";
1780 }
1781 
1782 void TypePrinter::printBTFTagAttributedBefore(const BTFTagAttributedType *T,
1783  raw_ostream &OS) {
1784  printBefore(T->getWrappedType(), OS);
1785  OS << " btf_type_tag(" << T->getAttr()->getBTFTypeTag() << ")";
1786 }
1787 
1788 void TypePrinter::printBTFTagAttributedAfter(const BTFTagAttributedType *T,
1789  raw_ostream &OS) {
1790  printAfter(T->getWrappedType(), OS);
1791 }
1792 
1793 void TypePrinter::printObjCInterfaceBefore(const ObjCInterfaceType *T,
1794  raw_ostream &OS) {
1795  OS << T->getDecl()->getName();
1796  spaceBeforePlaceHolder(OS);
1797 }
1798 
1799 void TypePrinter::printObjCInterfaceAfter(const ObjCInterfaceType *T,
1800  raw_ostream &OS) {}
1801 
1802 void TypePrinter::printObjCTypeParamBefore(const ObjCTypeParamType *T,
1803  raw_ostream &OS) {
1804  OS << T->getDecl()->getName();
1805  if (!T->qual_empty()) {
1806  bool isFirst = true;
1807  OS << '<';
1808  for (const auto *I : T->quals()) {
1809  if (isFirst)
1810  isFirst = false;
1811  else
1812  OS << ',';
1813  OS << I->getName();
1814  }
1815  OS << '>';
1816  }
1817 
1818  spaceBeforePlaceHolder(OS);
1819 }
1820 
1821 void TypePrinter::printObjCTypeParamAfter(const ObjCTypeParamType *T,
1822  raw_ostream &OS) {}
1823 
1824 void TypePrinter::printObjCObjectBefore(const ObjCObjectType *T,
1825  raw_ostream &OS) {
1826  if (T->qual_empty() && T->isUnspecializedAsWritten() &&
1827  !T->isKindOfTypeAsWritten())
1828  return printBefore(T->getBaseType(), OS);
1829 
1830  if (T->isKindOfTypeAsWritten())
1831  OS << "__kindof ";
1832 
1833  print(T->getBaseType(), OS, StringRef());
1834 
1835  if (T->isSpecializedAsWritten()) {
1836  bool isFirst = true;
1837  OS << '<';
1838  for (auto typeArg : T->getTypeArgsAsWritten()) {
1839  if (isFirst)
1840  isFirst = false;
1841  else
1842  OS << ",";
1843 
1844  print(typeArg, OS, StringRef());
1845  }
1846  OS << '>';
1847  }
1848 
1849  if (!T->qual_empty()) {
1850  bool isFirst = true;
1851  OS << '<';
1852  for (const auto *I : T->quals()) {
1853  if (isFirst)
1854  isFirst = false;
1855  else
1856  OS << ',';
1857  OS << I->getName();
1858  }
1859  OS << '>';
1860  }
1861 
1862  spaceBeforePlaceHolder(OS);
1863 }
1864 
1865 void TypePrinter::printObjCObjectAfter(const ObjCObjectType *T,
1866  raw_ostream &OS) {
1867  if (T->qual_empty() && T->isUnspecializedAsWritten() &&
1868  !T->isKindOfTypeAsWritten())
1869  return printAfter(T->getBaseType(), OS);
1870 }
1871 
1872 void TypePrinter::printObjCObjectPointerBefore(const ObjCObjectPointerType *T,
1873  raw_ostream &OS) {
1874  printBefore(T->getPointeeType(), OS);
1875 
1876  // If we need to print the pointer, print it now.
1877  if (!T->isObjCIdType() && !T->isObjCQualifiedIdType() &&
1878  !T->isObjCClassType() && !T->isObjCQualifiedClassType()) {
1879  if (HasEmptyPlaceHolder)
1880  OS << ' ';
1881  OS << '*';
1882  }
1883 }
1884 
1885 void TypePrinter::printObjCObjectPointerAfter(const ObjCObjectPointerType *T,
1886  raw_ostream &OS) {}
1887 
1888 static
1889 const TemplateArgument &getArgument(const TemplateArgument &A) { return A; }
1890 
1891 static const TemplateArgument &getArgument(const TemplateArgumentLoc &A) {
1892  return A.getArgument();
1893 }
1894 
1895 static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP,
1896  llvm::raw_ostream &OS, bool IncludeType) {
1897  A.print(PP, OS, IncludeType);
1898 }
1899 
1900 static void printArgument(const TemplateArgumentLoc &A,
1901  const PrintingPolicy &PP, llvm::raw_ostream &OS,
1902  bool IncludeType) {
1903  const TemplateArgument::ArgKind &Kind = A.getArgument().getKind();
1904  if (Kind == TemplateArgument::ArgKind::Type)
1905  return A.getTypeSourceInfo()->getType().print(OS, PP);
1906  return A.getArgument().print(PP, OS, IncludeType);
1907 }
1908 
1909 static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg,
1910  TemplateArgument Pattern,
1911  ArrayRef<TemplateArgument> Args,
1912  unsigned Depth);
1913 
1914 static bool isSubstitutedType(ASTContext &Ctx, QualType T, QualType Pattern,
1915  ArrayRef<TemplateArgument> Args, unsigned Depth) {
1916  if (Ctx.hasSameType(T, Pattern))
1917  return true;
1918 
1919  // A type parameter matches its argument.
1920  if (auto *TTPT = Pattern->getAs<TemplateTypeParmType>()) {
1921  if (TTPT->getDepth() == Depth && TTPT->getIndex() < Args.size() &&
1922  Args[TTPT->getIndex()].getKind() == TemplateArgument::Type) {
1923  QualType SubstArg = Ctx.getQualifiedType(
1924  Args[TTPT->getIndex()].getAsType(), Pattern.getQualifiers());
1925  return Ctx.hasSameType(SubstArg, T);
1926  }
1927  return false;
1928  }
1929 
1930  // FIXME: Recurse into array types.
1931 
1932  // All other cases will need the types to be identically qualified.
1933  Qualifiers TQual, PatQual;
1934  T = Ctx.getUnqualifiedArrayType(T, TQual);
1935  Pattern = Ctx.getUnqualifiedArrayType(Pattern, PatQual);
1936  if (TQual != PatQual)
1937  return false;
1938 
1939  // Recurse into pointer-like types.
1940  {
1941  QualType TPointee = T->getPointeeType();
1942  QualType PPointee = Pattern->getPointeeType();
1943  if (!TPointee.isNull() && !PPointee.isNull())
1944  return T->getTypeClass() == Pattern->getTypeClass() &&
1945  isSubstitutedType(Ctx, TPointee, PPointee, Args, Depth);
1946  }
1947 
1948  // Recurse into template specialization types.
1949  if (auto *PTST =
1950  Pattern.getCanonicalType()->getAs<TemplateSpecializationType>()) {
1951  TemplateName Template;
1952  ArrayRef<TemplateArgument> TemplateArgs;
1953  if (auto *TTST = T->getAs<TemplateSpecializationType>()) {
1954  Template = TTST->getTemplateName();
1955  TemplateArgs = TTST->template_arguments();
1956  } else if (auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
1957  T->getAsCXXRecordDecl())) {
1958  Template = TemplateName(CTSD->getSpecializedTemplate());
1959  TemplateArgs = CTSD->getTemplateArgs().asArray();
1960  } else {
1961  return false;
1962  }
1963 
1964  if (!isSubstitutedTemplateArgument(Ctx, Template, PTST->getTemplateName(),
1965  Args, Depth))
1966  return false;
1967  if (TemplateArgs.size() != PTST->getNumArgs())
1968  return false;
1969  for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
1970  if (!isSubstitutedTemplateArgument(Ctx, TemplateArgs[I], PTST->getArg(I),
1971  Args, Depth))
1972  return false;
1973  return true;
1974  }
1975 
1976  // FIXME: Handle more cases.
1977  return false;
1978 }
1979 
1980 static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg,
1981  TemplateArgument Pattern,
1982  ArrayRef<TemplateArgument> Args,
1983  unsigned Depth) {
1984  Arg = Ctx.getCanonicalTemplateArgument(Arg);
1985  Pattern = Ctx.getCanonicalTemplateArgument(Pattern);
1986  if (Arg.structurallyEquals(Pattern))
1987  return true;
1988 
1989  if (Pattern.getKind() == TemplateArgument::Expression) {
1990  if (auto *DRE =
1991  dyn_cast<DeclRefExpr>(Pattern.getAsExpr()->IgnoreParenImpCasts())) {
1992  if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
1993  return NTTP->getDepth() == Depth && Args.size() > NTTP->getIndex() &&
1994  Args[NTTP->getIndex()].structurallyEquals(Arg);
1995  }
1996  }
1997 
1998  if (Arg.getKind() != Pattern.getKind())
1999  return false;
2000 
2001  if (Arg.getKind() == TemplateArgument::Type)
2002  return isSubstitutedType(Ctx, Arg.getAsType(), Pattern.getAsType(), Args,
2003  Depth);
2004 
2005  if (Arg.getKind() == TemplateArgument::Template) {
2006  TemplateDecl *PatTD = Pattern.getAsTemplate().getAsTemplateDecl();
2007  if (auto *TTPD = dyn_cast_or_null<TemplateTemplateParmDecl>(PatTD))
2008  return TTPD->getDepth() == Depth && Args.size() > TTPD->getIndex() &&
2009  Ctx.getCanonicalTemplateArgument(Args[TTPD->getIndex()])
2010  .structurallyEquals(Arg);
2011  }
2012 
2013  // FIXME: Handle more cases.
2014  return false;
2015 }
2016 
2017 /// Make a best-effort determination of whether the type T can be produced by
2018 /// substituting Args into the default argument of Param.
2019 static bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
2020  const NamedDecl *Param,
2021  ArrayRef<TemplateArgument> Args,
2022  unsigned Depth) {
2023  // An empty pack is equivalent to not providing a pack argument.
2024  if (Arg.getKind() == TemplateArgument::Pack && Arg.pack_size() == 0)
2025  return true;
2026 
2027  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2028  return TTPD->hasDefaultArgument() &&
2029  isSubstitutedTemplateArgument(Ctx, Arg, TTPD->getDefaultArgument(),
2030  Args, Depth);
2031  } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2032  return TTPD->hasDefaultArgument() &&
2033  isSubstitutedTemplateArgument(
2034  Ctx, Arg, TTPD->getDefaultArgument().getArgument(), Args, Depth);
2035  } else if (auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2036  return NTTPD->hasDefaultArgument() &&
2037  isSubstitutedTemplateArgument(Ctx, Arg, NTTPD->getDefaultArgument(),
2038  Args, Depth);
2039  }
2040  return false;
2041 }
2042 
2043 template <typename TA>
2044 static void
2045 printTo(raw_ostream &OS, ArrayRef<TA> Args, const PrintingPolicy &Policy,
2046  const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex) {
2047  // Drop trailing template arguments that match default arguments.
2048  if (TPL && Policy.SuppressDefaultTemplateArgs &&
2049  !Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
2050  Args.size() <= TPL->size()) {
2051  ASTContext &Ctx = TPL->getParam(0)->getASTContext();
2052  llvm::SmallVector<TemplateArgument, 8> OrigArgs;
2053  for (const TA &A : Args)
2054  OrigArgs.push_back(getArgument(A));
2055  while (!Args.empty() &&
2056  isSubstitutedDefaultArgument(Ctx, getArgument(Args.back()),
2057  TPL->getParam(Args.size() - 1),
2058  OrigArgs, TPL->getDepth()))
2059  Args = Args.drop_back();
2060  }
2061 
2062  const char *Comma = Policy.MSVCFormatting ? "," : ", ";
2063  if (!IsPack)
2064  OS << '<';
2065 
2066  bool NeedSpace = false;
2067  bool FirstArg = true;
2068  for (const auto &Arg : Args) {
2069  // Print the argument into a string.
2070  SmallString<128> Buf;
2071  llvm::raw_svector_ostream ArgOS(Buf);
2072  const TemplateArgument &Argument = getArgument(Arg);
2073  if (Argument.getKind() == TemplateArgument::Pack) {
2074  if (Argument.pack_size() && !FirstArg)
2075  OS << Comma;
2076  printTo(ArgOS, Argument.getPackAsArray(), Policy, TPL,
2077  /*IsPack*/ true, ParmIndex);
2078  } else {
2079  if (!FirstArg)
2080  OS << Comma;
2081  // Tries to print the argument with location info if exists.
2082  printArgument(Arg, Policy, ArgOS,
2083  TemplateParameterList::shouldIncludeTypeForArgument(
2084  Policy, TPL, ParmIndex));
2085  }
2086  StringRef ArgString = ArgOS.str();
2087 
2088  // If this is the first argument and its string representation
2089  // begins with the global scope specifier ('::foo'), add a space
2090  // to avoid printing the diagraph '<:'.
2091  if (FirstArg && !ArgString.empty() && ArgString[0] == ':')
2092  OS << ' ';
2093 
2094  OS << ArgString;
2095 
2096  // If the last character of our string is '>', add another space to
2097  // keep the two '>''s separate tokens.
2098  if (!ArgString.empty()) {
2099  NeedSpace = Policy.SplitTemplateClosers && ArgString.back() == '>';
2100  FirstArg = false;
2101  }
2102 
2103  // Use same template parameter for all elements of Pack
2104  if (!IsPack)
2105  ParmIndex++;
2106  }
2107 
2108  if (!IsPack) {
2109  if (NeedSpace)
2110  OS << ' ';
2111  OS << '>';
2112  }
2113 }
2114 
2115 void clang::printTemplateArgumentList(raw_ostream &OS,
2116  const TemplateArgumentListInfo &Args,
2117  const PrintingPolicy &Policy,
2118  const TemplateParameterList *TPL) {
2119  printTemplateArgumentList(OS, Args.arguments(), Policy, TPL);
2120 }
2121 
2122 void clang::printTemplateArgumentList(raw_ostream &OS,
2123  ArrayRef<TemplateArgument> Args,
2124  const PrintingPolicy &Policy,
2125  const TemplateParameterList *TPL) {
2126  printTo(OS, Args, Policy, TPL, /*isPack*/ false, /*parmIndex*/ 0);
2127 }
2128 
2129 void clang::printTemplateArgumentList(raw_ostream &OS,
2130  ArrayRef<TemplateArgumentLoc> Args,
2131  const PrintingPolicy &Policy,
2132  const TemplateParameterList *TPL) {
2133  printTo(OS, Args, Policy, TPL, /*isPack*/ false, /*parmIndex*/ 0);
2134 }
2135 
2136 std::string Qualifiers::getAsString() const {
2137  LangOptions LO;
2138  return getAsString(PrintingPolicy(LO));
2139 }
2140 
2141 // Appends qualifiers to the given string, separated by spaces. Will
2142 // prefix a space if the string is non-empty. Will not append a final
2143 // space.
2144 std::string Qualifiers::getAsString(const PrintingPolicy &Policy) const {
2145  SmallString<64> Buf;
2146  llvm::raw_svector_ostream StrOS(Buf);
2147  print(StrOS, Policy);
2148  return std::string(StrOS.str());
2149 }
2150 
2151 bool Qualifiers::isEmptyWhenPrinted(const PrintingPolicy &Policy) const {
2152  if (getCVRQualifiers())
2153  return false;
2154 
2155  if (getAddressSpace() != LangAS::Default)
2156  return false;
2157 
2158  if (getObjCGCAttr())
2159  return false;
2160 
2161  if (Qualifiers::ObjCLifetime lifetime = getObjCLifetime())
2162  if (!(lifetime == Qualifiers::OCL_Strong && Policy.SuppressStrongLifetime))
2163  return false;
2164 
2165  return true;
2166 }
2167 
2168 std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
2169  switch (AS) {
2170  case LangAS::Default:
2171  return "";
2172  case LangAS::opencl_global:
2173  case LangAS::sycl_global:
2174  return "__global";
2175  case LangAS::opencl_local:
2176  case LangAS::sycl_local:
2177  return "__local";
2178  case LangAS::opencl_private:
2179  case LangAS::sycl_private:
2180  return "__private";
2181  case LangAS::opencl_constant:
2182  return "__constant";
2183  case LangAS::opencl_generic:
2184  return "__generic";
2185  case LangAS::opencl_global_device:
2186  case LangAS::sycl_global_device:
2187  return "__global_device";
2188  case LangAS::opencl_global_host:
2189  case LangAS::sycl_global_host:
2190  return "__global_host";
2191  case LangAS::cuda_device:
2192  return "__device__";
2193  case LangAS::cuda_constant:
2194  return "__constant__";
2195  case LangAS::cuda_shared:
2196  return "__shared__";
2197  case LangAS::ptr32_sptr:
2198  return "__sptr __ptr32";
2199  case LangAS::ptr32_uptr:
2200  return "__uptr __ptr32";
2201  case LangAS::ptr64:
2202  return "__ptr64";
2203  default:
2204  return std::to_string(toTargetAddressSpace(AS));
2205  }
2206 }
2207 
2208 // Appends qualifiers to the given string, separated by spaces. Will
2209 // prefix a space if the string is non-empty. Will not append a final
2210 // space.
2211 void Qualifiers::print(raw_ostream &OS, const PrintingPolicy& Policy,
2212  bool appendSpaceIfNonEmpty) const {
2213  bool addSpace = false;
2214 
2215  unsigned quals = getCVRQualifiers();
2216  if (quals) {
2217  AppendTypeQualList(OS, quals, Policy.Restrict);
2218  addSpace = true;
2219  }
2220  if (hasUnaligned()) {
2221  if (addSpace)
2222  OS << ' ';
2223  OS << "__unaligned";
2224  addSpace = true;
2225  }
2226  auto ASStr = getAddrSpaceAsString(getAddressSpace());
2227  if (!ASStr.empty()) {
2228  if (addSpace)
2229  OS << ' ';
2230  addSpace = true;
2231  // Wrap target address space into an attribute syntax
2232  if (isTargetAddressSpace(getAddressSpace()))
2233  OS << "__attribute__((address_space(" << ASStr << ")))";
2234  else
2235  OS << ASStr;
2236  }
2237 
2238  if (Qualifiers::GC gc = getObjCGCAttr()) {
2239  if (addSpace)
2240  OS << ' ';
2241  addSpace = true;
2242  if (gc == Qualifiers::Weak)
2243  OS << "__weak";
2244  else
2245  OS << "__strong";
2246  }
2247  if (Qualifiers::ObjCLifetime lifetime = getObjCLifetime()) {
2248  if (!(lifetime == Qualifiers::OCL_Strong && Policy.SuppressStrongLifetime)){
2249  if (addSpace)
2250  OS << ' ';
2251  addSpace = true;
2252  }
2253 
2254  switch (lifetime) {
2255  case Qualifiers::OCL_None: llvm_unreachable("none but true");
2256  case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break;
2257  case Qualifiers::OCL_Strong:
2258  if (!Policy.SuppressStrongLifetime)
2259  OS << "__strong";
2260  break;
2261 
2262  case Qualifiers::OCL_Weak: OS << "__weak"; break;
2263  case Qualifiers::OCL_Autoreleasing: OS << "__autoreleasing"; break;
2264  }
2265  }
2266 
2267  if (appendSpaceIfNonEmpty && addSpace)
2268  OS << ' ';
2269 }
2270 
2271 std::string QualType::getAsString() const {
2272  return getAsString(split(), LangOptions());
2273 }
2274 
2275 std::string QualType::getAsString(const PrintingPolicy &Policy) const {
2276  std::string S;
2277  getAsStringInternal(S, Policy);
2278  return S;
2279 }
2280 
2281 std::string QualType::getAsString(const Type *ty, Qualifiers qs,
2282  const PrintingPolicy &Policy) {
2283  std::string buffer;
2284  getAsStringInternal(ty, qs, buffer, Policy);
2285  return buffer;
2286 }
2287 
2288 void QualType::print(raw_ostream &OS, const PrintingPolicy &Policy,
2289  const Twine &PlaceHolder, unsigned Indentation) const {
2290  print(splitAccordingToPolicy(*this, Policy), OS, Policy, PlaceHolder,
2291  Indentation);
2292 }
2293 
2294 void QualType::print(const Type *ty, Qualifiers qs,
2295  raw_ostream &OS, const PrintingPolicy &policy,
2296  const Twine &PlaceHolder, unsigned Indentation) {
2297  SmallString<128> PHBuf;
2298  StringRef PH = PlaceHolder.toStringRef(PHBuf);
2299 
2300  TypePrinter(policy, Indentation).print(ty, qs, OS, PH);
2301 }
2302 
2303 void QualType::getAsStringInternal(std::string &Str,
2304  const PrintingPolicy &Policy) const {
2305  return getAsStringInternal(splitAccordingToPolicy(*this, Policy), Str,
2306  Policy);
2307 }
2308 
2309 void QualType::getAsStringInternal(const Type *ty, Qualifiers qs,
2310  std::string &buffer,
2311  const PrintingPolicy &policy) {
2312  SmallString<256> Buf;
2313  llvm::raw_svector_ostream StrOS(Buf);
2314  TypePrinter(policy).print(ty, qs, StrOS, buffer);
2315  std::string str = std::string(StrOS.str());
2316  buffer.swap(str);
2317 }
2318 
2319 raw_ostream &clang::operator<<(raw_ostream &OS, QualType QT) {
2320  SplitQualType S = QT.split();
2321  TypePrinter(LangOptions()).print(S.Ty, S.Quals, OS, /*PlaceHolder=*/"");
2322  return OS;
2323 }
clang::BuiltinType
This class is used for builtin types like 'int'.
Definition: Type.h:2504
clang::TagDecl::getKindName
StringRef getKindName() const
Definition: Decl.h:3541
clang::DependentTemplateSpecializationType::getIdentifier
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5644
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:414
clang::PipeType::isReadOnly
bool isReadOnly() const
Definition: Type.h:6378
clang::DeducedTemplateSpecializationType
Represents a C++17 deduced template specialization type.
Definition: Type.h:5118
clang::ParenType::getInnerType
QualType getInnerType() const
Definition: Type.h:2636
clang::FunctionProtoType::hasTrailingReturn
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4246
clang::CC_X86FastCall
@ CC_X86FastCall
Definition: Specifiers.h:266
clang::PrintingPolicy::SuppressScope
unsigned SuppressScope
Suppresses printing of scope specifiers.
Definition: PrettyPrinter.h:130
Specifiers.h
clang::FunctionProtoType::getExceptionSpecType
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition: Type.h:4133
clang::DependentSizedExtVectorType::getSizeExpr
Expr * getSizeExpr() const
Definition: Type.h:3217
clang::CC_Win64
@ CC_Win64
Definition: Specifiers.h:270
clang::AutoTypeKeyword::GNUAutoType
@ GNUAutoType
__auto_type (GNU extension)
clang::UsingType::getFoundDecl
UsingShadowDecl * getFoundDecl() const
Definition: Type.h:4391
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6482
clang::AttributedType
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4702
clang::getParameterABISpelling
llvm::StringRef getParameterABISpelling(ParameterABI kind)
Definition: TypePrinter.cpp:847
clang::TemplateTypeParmType::getDecl
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:4878
clang::VectorType::SveFixedLengthPredicateVector
@ SveFixedLengthPredicateVector
is AArch64 SVE fixed-length predicate vector
Definition: Type.h:3267
clang::BuiltinType::getName
StringRef getName(const PrintingPolicy &Policy) const
Definition: Type.cpp:2979
clang::AttributedType::getImmediateNullability
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:4231
clang::DeclaratorContext::File
@ File
clang::AutoType::isConstrained
bool isConstrained() const
Definition: Type.h:5086
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1356
clang::PresumedLoc::getLine
unsigned getLine() const
Return the presumed line number of this location.
Definition: SourceLocation.h:337
clang::AutoType::getTypeConstraintConcept
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:5082
clang::PipeType::getElementType
QualType getElementType() const
Definition: Type.h:6359
clang::ParameterABI::SwiftAsyncContext
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
clang::ConstantArrayType
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2942
clang::FunctionProtoType::hasDynamicExceptionSpec
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
Definition: Type.h:4142
clang::InjectedClassNameType::getInjectedTST
const TemplateSpecializationType * getInjectedTST() const
Definition: Type.h:5365
clang::AttributedType::isCallingConv
bool isCallingConv() const
Definition: Type.cpp:3611
clang::DependentSizedArrayType::getSizeExpr
Expr * getSizeExpr() const
Definition: Type.h:3122
clang::DependentNameType::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5584
clang::ParameterABI::Ordinary
@ Ordinary
This parameter uses ordinary ABI rules for its type.
clang::ConstantArrayType::getSize
const llvm::APInt & getSize() const
Definition: Type.h:2965
clang::DependentBitIntType::isUnsigned
bool isUnsigned() const
Definition: Type.cpp:351
clang::UnaryTransformType::EnumUnderlyingType
@ EnumUnderlyingType
Definition: Type.h:4568
clang::QualType::getQualifiers
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:6527
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::DependentAddressSpaceType::getAddrSpaceExpr
Expr * getAddrSpaceExpr() const
Definition: Type.h:3173
clang::TemplateTypeParmType::getIdentifier
IdentifierInfo * getIdentifier() const
Definition: Type.cpp:3642
clang::NamedDecl::getUnderlyingDecl
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:457
clang::UsingType
Definition: Type.h:4384
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
clang::TypeDecl::getTypeForDecl
const Type * getTypeForDecl() const
Definition: Decl.h:3182
Attr.h
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:108
clang::Qualifiers::getAsString
std::string getAsString() const
Definition: TypePrinter.cpp:2136
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::DecltypeType::getUnderlyingExpr
Expr * getUnderlyingExpr() const
Definition: Type.h:4532
clang::Qualifiers::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool appendSpaceIfNonEmpty=false) const
Definition: TypePrinter.cpp:2211
clang::QualType::getCanonicalType
QualType getCanonicalType() const
Definition: Type.h:6539
clang::VectorType::NeonVector
@ NeonVector
is ARM Neon vector
Definition: Type.h:3258
clang::FunctionType::ExtInfo::getNoCallerSavedRegs
bool getNoCallerSavedRegs() const
Definition: Type.h:3721
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:147
clang::PipeType
PipeType - OpenCL20.
Definition: Type.h:6348
DeclCXX.h
clang::AttributedType::isMSTypeSpec
bool isMSTypeSpec() const
Definition: Type.cpp:3598
clang::DependentVectorType::getElementType
QualType getElementType() const
Definition: Type.h:3335
AppendTypeQualList
static void AppendTypeQualList(raw_ostream &OS, unsigned TypeQuals, bool HasRestrictKeyword)
Definition: TypePrinter.cpp:141
clang::TemplateSpecializationType
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:5179
clang::BitIntType::getNumBits
unsigned getNumBits() const
Definition: Type.h:6393
clang::FunctionType::getExtInfo
ExtInfo getExtInfo() const
Definition: Type.h:3834
clang::ComplexType::getElementType
QualType getElementType() const
Definition: Type.h:2610
clang::ObjCTypeParamType::getDecl
ObjCTypeParamDecl * getDecl() const
Definition: Type.h:5861
clang::RQ_RValue
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
Definition: Type.h:1459
SourceManager.h
clang::SourceManager::getPresumedLoc
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
Definition: SourceManager.cpp:1513
clang::MacroQualifiedType::getModifiedType
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
Definition: Type.cpp:3454
clang::TagDecl::getTypedefNameForAnonDecl
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3576
clang::Qualifiers::empty
bool empty() const
Definition: Type.h:425
clang::printTemplateArgumentList
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.
Definition: TypePrinter.cpp:2122
clang::CC_X86ThisCall
@ CC_X86ThisCall
Definition: Specifiers.h:267
clang::isComputedNoexcept
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:39
clang::ReferenceType::getPointeeTypeAsWritten
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2780
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::VectorType::NeonPolyVector
@ NeonPolyVector
is ARM Neon polynomial vector
Definition: Type.h:3261
clang::AutoType::getTypeConstraintArguments
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:5078
clang::ObjCInterfaceType::getDecl
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.cpp:823
print
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
Definition: InterpFrame.cpp:62
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
clang::QualType::stream
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: Type.h:1079
clang::FunctionNoProtoType
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:3860
clang::BitIntType::isUnsigned
bool isUnsigned() const
Definition: Type.h:6391
TemplateName.h
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::ASTContext::getSourceManager
SourceManager & getSourceManager()
Definition: ASTContext.h:716
clang::Qualifiers::Restrict
@ Restrict
Definition: Type.h:151
clang::BTFTagAttributedType
Definition: Type.h:4799
clang::DependentSizedMatrixType
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Definition: Type.h:3527
Paren
@ Paren
Definition: PPMacroExpansion.cpp:631
clang::CC_X86StdCall
@ CC_X86StdCall
Definition: Specifiers.h:265
clang::ArrayType::Star
@ Star
Definition: Type.h:2903
clang::FunctionProtoType::isVariadic
bool isVariadic() const
Whether this function prototype is variadic.
Definition: Type.h:4230
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1500
Decl.h
clang::CC_OpenCLKernel
@ CC_OpenCLKernel
Definition: Specifiers.h:277
clang::SubstTemplateTypeParmPackType::getReplacedParameter
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4983
clang::FunctionProtoType::printExceptionSpecification
void printExceptionSpecification(raw_ostream &OS, const PrintingPolicy &Policy) const
Definition: TypePrinter.cpp:802
clang::TypedefType
Definition: Type.h:4405
DeclObjC.h
AddressSpaces.h
PrettyPrinter.h
clang::TypeWithKeyword::getKeywordName
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
Definition: Type.cpp:2906
clang::ArrayType::getIndexTypeCVRQualifiers
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2927
clang::Type::isObjCClassType
bool isObjCClassType() const
Definition: Type.h:6915
TemplateBase.h
clang::CC_Swift
@ CC_Swift
Definition: Specifiers.h:278
clang::PackExpansionType::getPattern
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5729
clang::ParameterABI
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:345
clang::ElaboratedType
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:5479
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4647
DeclTemplate.h
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5708
clang::VectorType::SveFixedLengthDataVector
@ SveFixedLengthDataVector
is AArch64 SVE fixed-length data vector
Definition: Type.h:3264
clang::Stmt::printPretty
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2635
clang::Decl::specific_attrs
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:524
clang::TemplateTypeParmType::getIndex
unsigned getIndex() const
Definition: Type.h:4875
Id
int Id
Definition: ASTDiff.cpp:191
ExceptionSpecificationType.h
DeclBase.h
clang::MacroQualifiedType::getMacroIdentifier
const IdentifierInfo * getMacroIdentifier() const
Definition: Type.h:4440
clang::PresumedLoc::getFilename
const char * getFilename() const
Return the presumed filename of this location.
Definition: SourceLocation.h:324
clang::FunctionType::ExtInfo::getNoReturn
bool getNoReturn() const
Definition: Type.h:3718
clang::Type::isObjCIdType
bool isObjCIdType() const
Definition: Type.h:6909
clang::PrintingPolicy::SuppressSpecifiers
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
Definition: PrettyPrinter.h:107
splitAccordingToPolicy
static SplitQualType splitAccordingToPolicy(QualType QT, const PrintingPolicy &Policy)
Definition: TypePrinter.cpp:168
clang::VectorType
Represents a GCC generic vector type.
Definition: Type.h:3242
NestedNameSpecifier.h
clang::ConstantMatrixType
Represents a concrete matrix type with constant number of rows and columns.
Definition: Type.h:3468
LangOptions.h
clang::syntax::NodeRole::Qualifier
@ Qualifier
clang::MemberPointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2860
clang::DependentVectorType::getSizeExpr
Expr * getSizeExpr() const
Definition: Type.h:3334
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7243
clang::TypeOfType
Represents typeof(type), a GCC extension.
Definition: Type.h:4499
clang::AutoType::getKeyword
AutoTypeKeyword getKeyword() const
Definition: Type.h:5098
clang::CC_AMDGPUKernelCall
@ CC_AMDGPUKernelCall
Definition: Specifiers.h:284
clang::ParameterABI::SwiftIndirectResult
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
clang::SubstTemplateTypeParmType::getReplacementType
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4930
clang::FunctionProtoType::getParamType
QualType getParamType(unsigned i) const
Definition: Type.h:4110
clang::Qualifiers::Volatile
@ Volatile
Definition: Type.h:152
clang::MacroQualifiedType
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Definition: Type.h:4425
IdentifierTable.h
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1951
clang::AutoType
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5048
clang::ConstantMatrixType::getNumColumns
unsigned getNumColumns() const
Returns the number of columns in the matrix.
Definition: Type.h:3489
clang::Type::isFunctionType
bool isFunctionType() const
Definition: Type.h:6744
clang::VariableArrayType::getSizeExpr
Expr * getSizeExpr() const
Definition: Type.h:3065
Type.h
Expr.h
ASTContext.h
clang::UnresolvedUsingType
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition: Type.h:4354
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3348
clang::FunctionType::ExtInfo::getNoCfCheck
bool getNoCfCheck() const
Definition: Type.h:3722
clang::SplitQualType::Ty
const Type * Ty
The locally-unqualified type.
Definition: Type.h:616
clang::PresumedLoc::getColumn
unsigned getColumn() const
Return the presumed column number of this location.
Definition: SourceLocation.h:345
clang::RQ_None
@ RQ_None
No ref-qualifier was provided.
Definition: Type.h:1453
clang::DependentAddressSpaceType
Represents an extended address space qualifier where the input address space value is dependent.
Definition: Type.h:3160
clang::SubstTemplateTypeParmType
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4912
clang::DependentAddressSpaceType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:3174
clang::MemberPointerType::getClass
const Type * getClass() const
Definition: Type.h:2874
clang::Type::getLocallyUnqualifiedSingleStepDesugaredType
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
Definition: Type.cpp:422
clang::Qualifiers::isEmptyWhenPrinted
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const
Definition: TypePrinter.cpp:2151
clang::PrintingPolicy::SuppressTagKeyword
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
Definition: PrettyPrinter.h:117
clang::SubstTemplateTypeParmPackType
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:4965
clang::MatrixType::getElementType
QualType getElementType() const
Returns type of the elements being stored in the matrix.
Definition: Type.h:3446
clang::ElaboratedType::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:5520
clang::VectorType::GenericVector
@ GenericVector
not a target-specific vector type
Definition: Type.h:3246
clang::AtomicType::getValueType
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6329
clang::VectorType::AltiVecPixel
@ AltiVecPixel
is AltiVec 'vector Pixel'
Definition: Type.h:3252
clang::DependentTemplateSpecializationType::template_arguments
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5658
clang::BlockPointerType
Pointer to a block type.
Definition: Type.h:2733
clang::Type::TypeClass
TypeClass
Definition: Type.h:1502
clang::FunctionProtoType::getRefQualifier
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Definition: Type.h:4256
clang::Type::isObjCQualifiedIdType
bool isObjCQualifiedIdType() const
Definition: Type.h:6897
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1196
clang::FunctionProtoType::getExceptionType
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
Definition: Type.h:4184
clang::Type::getTypeClass
TypeClass getTypeClass() const
Definition: Type.h:1868
clang::UnaryTransformType::getBaseType
QualType getBaseType() const
Definition: Type.h:4591
clang::AdjustedType
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Definition: Type.h:2682
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:558
clang::QualType::split
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6508
clang::BitIntType
A fixed int type of a specified bitwidth.
Definition: Type.h:6382
clang::IncompleteArrayType
Represents a C array with an unspecified size.
Definition: Type.h:3002
clang::VectorType::getVectorKind
VectorKind getVectorKind() const
Definition: Type.h:3289
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:419
clang::ETK_None
@ ETK_None
No keyword precedes the qualified type name.
Definition: Type.h:5424
clang::CC_C
@ CC_C
Definition: Specifiers.h:264
clang::FunctionType::ExtInfo::getCmseNSCall
bool getCmseNSCall() const
Definition: Type.h:3720
clang::UnaryTransformType
A unary type transform, which is a type constructed from another.
Definition: Type.h:4565
clang::PrintingPolicy::IncludeTagDefinition
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
Definition: PrettyPrinter.h:127
clang::TemplateArgumentList::asArray
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Definition: DeclTemplate.h:291
clang::TemplateTypeParmType
Definition: Type.h:4833
clang::DeducedType::getDeducedType
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Definition: Type.h:5035
clang::ArrayType::getIndexTypeQualifiers
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2923
clang::Type::castAs
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:7310
clang::ObjCProtocolQualifiers::qual_empty
bool qual_empty() const
Definition: Type.h:5795
clang::ArrayType::getSizeModifier
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2919
SourceLocation.h
clang::PrintingPolicy::PrintCanonicalTypes
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
Definition: PrettyPrinter.h:270
clang::AdjustedType::getAdjustedType
QualType getAdjustedType() const
Definition: Type.h:2696
clang::VectorType::AltiVecVector
@ AltiVecVector
is AltiVec vector
Definition: Type.h:3249
clang::DependentSizedArrayType
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3100
clang::NestedNameSpecifier::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Definition: NestedNameSpecifier.cpp:252
clang::VariableArrayType
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3046
clang::TemplateTypeParmDecl::getTypeConstraint
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
Definition: DeclTemplate.h:1363
clang::TypedefType::getDecl
TypedefNameDecl * getDecl() const
Definition: Type.h:4415
clang::CC_SpirFunction
@ CC_SpirFunction
Definition: Specifiers.h:276
clang::FunctionType::ExtInfo::getCC
CallingConv getCC() const
Definition: Type.h:3732
clang::ElaboratedType::getNamedType
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5523
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::ComplexType
Complex values, per C99 6.2.5p11.
Definition: Type.h:2600
clang::PrintingPolicy::SuppressLifetimeQualifiers
unsigned SuppressLifetimeQualifiers
When true, suppress printing of lifetime qualifier in ARC.
Definition: PrettyPrinter.h:181
clang::DependentSizedMatrixType::getRowExpr
Expr * getRowExpr() const
Definition: Type.h:3541
clang::BTFTagAttributedType::getWrappedType
QualType getWrappedType() const
Definition: Type.h:4812
clang::DecltypeType
Represents the type decltype(expr) (C++11).
Definition: Type.h:4522
clang::CC_PreserveAll
@ CC_PreserveAll
Definition: Specifiers.h:281
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3898
clang::TypeOfExprType::getUnderlyingExpr
Expr * getUnderlyingExpr() const
Definition: Type.h:4465
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1876
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:400
clang::BlockPointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2745
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:740
llvm::ArrayRef
Definition: LLVM.h:34
clang::FunctionProtoType::getNoexceptExpr
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
Definition: Type.h:4191
clang::DependentSizedMatrixType::getColumnExpr
Expr * getColumnExpr() const
Definition: Type.h:3542
clang::DependentSizedExtVectorType::getElementType
QualType getElementType() const
Definition: Type.h:3218
LLVM.h
clang::Type::isSpecifierType
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
Definition: Type.cpp:2813
clang::EST_MSAny
@ EST_MSAny
Microsoft throw(...) extension.
Definition: ExceptionSpecificationType.h:24
clang::CC_AAPCS
@ CC_AAPCS
Definition: Specifiers.h:273
llvm::SaveAndRestore< bool >
clang::FunctionProtoType::getNumParams
unsigned getNumParams() const
Definition: Type.h:4108
clang::Qualifiers::hasQualifiers
bool hasQualifiers() const
Return true if the set contains any qualifiers.
Definition: Type.h:424
DwarfFissionKind::Split
@ Split
clang::PrintingPolicy::SuppressStrongLifetime
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Definition: PrettyPrinter.h:178
clang::InjectedClassNameType
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:5332
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:237
clang::ElaboratedType::getOwnedTagDecl
TagDecl * getOwnedTagDecl() const
Return the (re)declaration of this type owned by this occurrence of this type, or nullptr if there is...
Definition: Type.h:5533
clang::TemplateSpecializationType::template_arguments
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5271
clang::CC_X86VectorCall
@ CC_X86VectorCall
Definition: Specifiers.h:268
clang::FunctionType::ExtInfo
A class which abstracts out some details necessary for making a call.
Definition: Type.h:3670
clang::AutoTypeKeyword::Auto
@ Auto
auto
clang::SplitQualType
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:614
clang::ArrayType::Static
@ Static
Definition: Type.h:2903
clang::EST_NoThrow
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
Definition: ExceptionSpecificationType.h:25
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::VectorType::AltiVecBool
@ AltiVecBool
is AltiVec 'vector bool ...'
Definition: Type.h:3255
clang::Type::isObjCQualifiedClassType
bool isObjCQualifiedClassType() const
Definition: Type.h:6903
clang::TypeOfExprType
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:4456
clang::FunctionProtoType::getMethodQuals
Qualifiers getMethodQuals() const
Definition: Type.h:4248
clang::MemberPointerType
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2844
clang::CC_IntelOclBicc
@ CC_IntelOclBicc
Definition: Specifiers.h:275
clang::DependentTemplateSpecializationType
Represents a template specialization type whose template cannot be resolved, e.g.
Definition: Type.h:5617
clang::CC_AArch64SVEPCS
@ CC_AArch64SVEPCS
Definition: Specifiers.h:283
clang::RValueReferenceType
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2826
clang::UnresolvedUsingType::getDecl
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:4365
clang::InjectedClassNameType::getTemplateName
TemplateName getTemplateName() const
Definition: Type.h:5369
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2653
clang::PresumedLoc::isValid
bool isValid() const
Definition: SourceLocation.h:319
clang::EnumType::getDecl
EnumDecl * getDecl() const
Definition: Type.h:4680
clang::TemplateName::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
Definition: TemplateName.cpp:247
clang::FunctionType::ExtInfo::getRegParm
unsigned getRegParm() const
Definition: Type.h:3725
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:195
clang::AttributedType::getEquivalentType
QualType getEquivalentType() const
Definition: Type.h:4725
clang::TemplateTypeParmType::getDepth
unsigned getDepth() const
Definition: Type.h:4874
clang::CC_AArch64VectorCall
@ CC_AArch64VectorCall
Definition: Specifiers.h:282
clang
Definition: CalledOnceCheck.h:17
clang::VectorType::getElementType
QualType getElementType() const
Definition: Type.h:3283
clang::BTFTagAttributedType::getAttr
const BTFTypeTagAttr * getAttr() const
Definition: Type.h:4813
clang::DeclarationName::print
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Definition: DeclarationName.cpp:138
clang::TypeOfType::getUnderlyingType
QualType getUnderlyingType() const
Definition: Type.h:4510
clang::CC_X86Pascal
@ CC_X86Pascal
Definition: Specifiers.h:269
clang::ParameterABI::SwiftErrorResult
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
clang::CC_X86RegCall
@ CC_X86RegCall
Definition: Specifiers.h:272
clang::Decl::print
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Definition: DeclPrinter.cpp:124
clang::CC_SwiftAsync
@ CC_SwiftAsync
Definition: Specifiers.h:279
clang::CC_PreserveMost
@ CC_PreserveMost
Definition: Specifiers.h:280
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6471
clang::FunctionType::getReturnType
QualType getReturnType() const
Definition: Type.h:3822
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:311
clang::ParameterABI::SwiftContext
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
s
__device__ __2f16 float bool s
Definition: __clang_hip_libdevice_declares.h:315
clang::Qualifiers::Const
@ Const
Definition: Type.h:150
clang::RQ_LValue
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
Definition: Type.h:1456
clang::CC_AAPCS_VFP
@ CC_AAPCS_VFP
Definition: Specifiers.h:274
skipTopLevelReferences
static QualType skipTopLevelReferences(QualType T)
Definition: TypePrinter.cpp:422
clang::DependentTemplateSpecializationType::getQualifier
NestedNameSpecifier * getQualifier() const
Definition: Type.h:5643
clang::ObjCProtocolQualifiers::quals
qual_range quals() const
Definition: Type.h:5791
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3200
clang::DependentVectorType
Represents a vector type where either the type or size is dependent.
Definition: Type.h:3321
clang::DependentNameType
Represents a qualified type name for which the type name is dependent.
Definition: Type.h:5566
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6500
clang::UnaryTransformType::getUTTKind
UTTKind getUTTKind() const
Definition: Type.h:4593
clang::RecordType::getDecl
RecordDecl * getDecl() const
Definition: Type.h:4657
clang::DeducedTemplateSpecializationType::getTemplateName
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:5139
clang::ExtVectorType
ExtVectorType - Extended vector type.
Definition: Type.h:3363
clang::DependentVectorType::getVectorKind
VectorType::VectorKind getVectorKind() const
Definition: Type.h:3337
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2764
clang::AttributedType::getAttrKind
Kind getAttrKind() const
Definition: Type.h:4720
clang::PointerType::getPointeeType
QualType getPointeeType() const
Definition: Type.h:2663
clang::VectorType::getNumElements
unsigned getNumElements() const
Definition: Type.h:3284
clang::AtomicType
Definition: Type.h:6318
clang::PresumedLoc
Represents an unpacked "presumed" location which can be presented to the user.
Definition: SourceLocation.h:302
clang::ObjCTypeParamType
Represents a type parameter type in Objective C.
Definition: Type.h:5817
clang::CC_X86_64SysV
@ CC_X86_64SysV
Definition: Specifiers.h:271
clang::ArrayType::getElementType
QualType getElementType() const
Definition: Type.h:2917
clang::EnumType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:4673
clang::DeclContext::isFunctionOrMethod
bool isFunctionOrMethod() const
Definition: DeclBase.h:1928
clang::FunctionProtoType::getExtParameterInfo
ExtParameterInfo getExtParameterInfo(unsigned I) const
Definition: Type.h:4311
clang::DependentSizedExtVectorType
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3202
clang::AttributedType::getModifiedType
QualType getModifiedType() const
Definition: Type.h:4724
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:425
clang::SplitQualType::Quals
Qualifiers Quals
The local qualifiers.
Definition: Type.h:619
clang::ConstantMatrixType::getNumRows
unsigned getNumRows() const
Returns the number of rows in the matrix.
Definition: Type.h:3486
clang::DependentNameType::getIdentifier
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5591
clang::FunctionType::ExtInfo::getProducesResult
bool getProducesResult() const
Definition: Type.h:3719
clang::TypeWithKeyword::getKeyword
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:5440
clang::DependentBitIntType
Definition: Type.h:6411
clang::ObjCInterfaceType
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:6092
clang::DependentBitIntType::getNumBitsExpr
Expr * getNumBitsExpr() const
Definition: Type.cpp:355
clang::DecayedType
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2716
clang::ParenType
Sugar for parentheses used when specifying types.
Definition: Type.h:2627
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1207
clang::LValueReferenceType
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2808
clang::FunctionProtoType::getNumExceptions
unsigned getNumExceptions() const
Return the number of types in the exception specification.
Definition: Type.h:4176
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:434
clang::TemplateSpecializationType::getTemplateName
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:5255
clang::isNoexceptExceptionSpec
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:44
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274
clang::AutoTypeKeyword::DecltypeAuto
@ DecltypeAuto
decltype(auto)