clang  16.0.0git
DeclPrinter.cpp
Go to the documentation of this file.
1 //===--- DeclPrinter.cpp - Printing implementation for Decl ASTs ----------===//
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 file implements the Decl::print method, which pretty prints the
10 // AST back out to C/Objective-C/C++/Objective-C++ code.
11 //
12 //===----------------------------------------------------------------------===//
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/Attr.h"
15 #include "clang/AST/Decl.h"
16 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/DeclVisitor.h"
20 #include "clang/AST/Expr.h"
21 #include "clang/AST/ExprCXX.h"
23 #include "clang/Basic/Module.h"
24 #include "llvm/Support/raw_ostream.h"
25 using namespace clang;
26 
27 namespace {
28  class DeclPrinter : public DeclVisitor<DeclPrinter> {
29  raw_ostream &Out;
31  const ASTContext &Context;
32  unsigned Indentation;
33  bool PrintInstantiation;
34 
35  raw_ostream& Indent() { return Indent(Indentation); }
36  raw_ostream& Indent(unsigned Indentation);
37  void ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls);
38 
39  void Print(AccessSpecifier AS);
40  void PrintConstructorInitializers(CXXConstructorDecl *CDecl,
41  std::string &Proto);
42 
43  /// Print an Objective-C method type in parentheses.
44  ///
45  /// \param Quals The Objective-C declaration qualifiers.
46  /// \param T The type to print.
47  void PrintObjCMethodType(ASTContext &Ctx, Decl::ObjCDeclQualifier Quals,
48  QualType T);
49 
50  void PrintObjCTypeParams(ObjCTypeParamList *Params);
51 
52  public:
53  DeclPrinter(raw_ostream &Out, const PrintingPolicy &Policy,
54  const ASTContext &Context, unsigned Indentation = 0,
55  bool PrintInstantiation = false)
56  : Out(Out), Policy(Policy), Context(Context), Indentation(Indentation),
57  PrintInstantiation(PrintInstantiation) {}
58 
59  void VisitDeclContext(DeclContext *DC, bool Indent = true);
60 
61  void VisitTranslationUnitDecl(TranslationUnitDecl *D);
62  void VisitTypedefDecl(TypedefDecl *D);
63  void VisitTypeAliasDecl(TypeAliasDecl *D);
64  void VisitEnumDecl(EnumDecl *D);
65  void VisitRecordDecl(RecordDecl *D);
66  void VisitEnumConstantDecl(EnumConstantDecl *D);
67  void VisitEmptyDecl(EmptyDecl *D);
68  void VisitFunctionDecl(FunctionDecl *D);
69  void VisitFriendDecl(FriendDecl *D);
70  void VisitFieldDecl(FieldDecl *D);
71  void VisitVarDecl(VarDecl *D);
72  void VisitLabelDecl(LabelDecl *D);
73  void VisitParmVarDecl(ParmVarDecl *D);
74  void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
75  void VisitImportDecl(ImportDecl *D);
76  void VisitStaticAssertDecl(StaticAssertDecl *D);
77  void VisitNamespaceDecl(NamespaceDecl *D);
78  void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
79  void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
80  void VisitCXXRecordDecl(CXXRecordDecl *D);
81  void VisitLinkageSpecDecl(LinkageSpecDecl *D);
82  void VisitTemplateDecl(const TemplateDecl *D);
83  void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
84  void VisitClassTemplateDecl(ClassTemplateDecl *D);
85  void VisitClassTemplateSpecializationDecl(
87  void VisitClassTemplatePartialSpecializationDecl(
89  void VisitObjCMethodDecl(ObjCMethodDecl *D);
90  void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
91  void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
92  void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
93  void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
94  void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
95  void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
96  void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
97  void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
98  void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
99  void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
100  void VisitUsingDecl(UsingDecl *D);
101  void VisitUsingEnumDecl(UsingEnumDecl *D);
102  void VisitUsingShadowDecl(UsingShadowDecl *D);
103  void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
104  void VisitOMPAllocateDecl(OMPAllocateDecl *D);
105  void VisitOMPRequiresDecl(OMPRequiresDecl *D);
106  void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
107  void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
108  void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
109  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP);
110  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *NTTP);
111  void VisitHLSLBufferDecl(HLSLBufferDecl *D);
112 
113  void printTemplateParameters(const TemplateParameterList *Params,
114  bool OmitTemplateKW = false);
115  void printTemplateArguments(llvm::ArrayRef<TemplateArgument> Args,
116  const TemplateParameterList *Params);
117  void printTemplateArguments(llvm::ArrayRef<TemplateArgumentLoc> Args,
118  const TemplateParameterList *Params);
119  void prettyPrintAttributes(Decl *D);
120  void prettyPrintPragmas(Decl *D);
121  void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
122  };
123 }
124 
125 void Decl::print(raw_ostream &Out, unsigned Indentation,
126  bool PrintInstantiation) const {
127  print(Out, getASTContext().getPrintingPolicy(), Indentation, PrintInstantiation);
128 }
129 
130 void Decl::print(raw_ostream &Out, const PrintingPolicy &Policy,
131  unsigned Indentation, bool PrintInstantiation) const {
132  DeclPrinter Printer(Out, Policy, getASTContext(), Indentation,
133  PrintInstantiation);
134  Printer.Visit(const_cast<Decl*>(this));
135 }
136 
137 void TemplateParameterList::print(raw_ostream &Out, const ASTContext &Context,
138  bool OmitTemplateKW) const {
139  print(Out, Context, Context.getPrintingPolicy(), OmitTemplateKW);
140 }
141 
142 void TemplateParameterList::print(raw_ostream &Out, const ASTContext &Context,
143  const PrintingPolicy &Policy,
144  bool OmitTemplateKW) const {
145  DeclPrinter Printer(Out, Policy, Context);
146  Printer.printTemplateParameters(this, OmitTemplateKW);
147 }
148 
150  // FIXME: This should be on the Type class!
151  QualType BaseType = T;
152  while (!BaseType->isSpecifierType()) {
153  if (const PointerType *PTy = BaseType->getAs<PointerType>())
154  BaseType = PTy->getPointeeType();
155  else if (const ObjCObjectPointerType *OPT =
156  BaseType->getAs<ObjCObjectPointerType>())
157  BaseType = OPT->getPointeeType();
158  else if (const BlockPointerType *BPy = BaseType->getAs<BlockPointerType>())
159  BaseType = BPy->getPointeeType();
160  else if (const ArrayType *ATy = dyn_cast<ArrayType>(BaseType))
161  BaseType = ATy->getElementType();
162  else if (const FunctionType *FTy = BaseType->getAs<FunctionType>())
163  BaseType = FTy->getReturnType();
164  else if (const VectorType *VTy = BaseType->getAs<VectorType>())
165  BaseType = VTy->getElementType();
166  else if (const ReferenceType *RTy = BaseType->getAs<ReferenceType>())
167  BaseType = RTy->getPointeeType();
168  else if (const AutoType *ATy = BaseType->getAs<AutoType>())
169  BaseType = ATy->getDeducedType();
170  else if (const ParenType *PTy = BaseType->getAs<ParenType>())
171  BaseType = PTy->desugar();
172  else
173  // This must be a syntax error.
174  break;
175  }
176  return BaseType;
177 }
178 
180  if (TypedefNameDecl* TDD = dyn_cast<TypedefNameDecl>(D))
181  return TDD->getUnderlyingType();
182  if (ValueDecl* VD = dyn_cast<ValueDecl>(D))
183  return VD->getType();
184  return QualType();
185 }
186 
187 void Decl::printGroup(Decl** Begin, unsigned NumDecls,
188  raw_ostream &Out, const PrintingPolicy &Policy,
189  unsigned Indentation) {
190  if (NumDecls == 1) {
191  (*Begin)->print(Out, Policy, Indentation);
192  return;
193  }
194 
195  Decl** End = Begin + NumDecls;
196  TagDecl* TD = dyn_cast<TagDecl>(*Begin);
197  if (TD)
198  ++Begin;
199 
200  PrintingPolicy SubPolicy(Policy);
201 
202  bool isFirst = true;
203  for ( ; Begin != End; ++Begin) {
204  if (isFirst) {
205  if(TD)
206  SubPolicy.IncludeTagDefinition = true;
207  SubPolicy.SuppressSpecifiers = false;
208  isFirst = false;
209  } else {
210  if (!isFirst) Out << ", ";
211  SubPolicy.IncludeTagDefinition = false;
212  SubPolicy.SuppressSpecifiers = true;
213  }
214 
215  (*Begin)->print(Out, SubPolicy, Indentation);
216  }
217 }
218 
219 LLVM_DUMP_METHOD void DeclContext::dumpDeclContext() const {
220  // Get the translation unit
221  const DeclContext *DC = this;
222  while (!DC->isTranslationUnit())
223  DC = DC->getParent();
224 
225  ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
226  DeclPrinter Printer(llvm::errs(), Ctx.getPrintingPolicy(), Ctx, 0);
227  Printer.VisitDeclContext(const_cast<DeclContext *>(this), /*Indent=*/false);
228 }
229 
230 raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
231  for (unsigned i = 0; i != Indentation; ++i)
232  Out << " ";
233  return Out;
234 }
235 
236 void DeclPrinter::prettyPrintAttributes(Decl *D) {
237  if (Policy.PolishForDeclaration)
238  return;
239 
240  if (D->hasAttrs()) {
241  AttrVec &Attrs = D->getAttrs();
242  for (auto *A : Attrs) {
243  if (A->isInherited() || A->isImplicit())
244  continue;
245  switch (A->getKind()) {
246 #define ATTR(X)
247 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
248 #include "clang/Basic/AttrList.inc"
249  break;
250  default:
251  A->printPretty(Out, Policy);
252  break;
253  }
254  }
255  }
256 }
257 
258 void DeclPrinter::prettyPrintPragmas(Decl *D) {
259  if (Policy.PolishForDeclaration)
260  return;
261 
262  if (D->hasAttrs()) {
263  AttrVec &Attrs = D->getAttrs();
264  for (auto *A : Attrs) {
265  switch (A->getKind()) {
266 #define ATTR(X)
267 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
268 #include "clang/Basic/AttrList.inc"
269  A->printPretty(Out, Policy);
270  Indent();
271  break;
272  default:
273  break;
274  }
275  }
276  }
277 }
278 
279 void DeclPrinter::printDeclType(QualType T, StringRef DeclName, bool Pack) {
280  // Normally, a PackExpansionType is written as T[3]... (for instance, as a
281  // template argument), but if it is the type of a declaration, the ellipsis
282  // is placed before the name being declared.
283  if (auto *PET = T->getAs<PackExpansionType>()) {
284  Pack = true;
285  T = PET->getPattern();
286  }
287  T.print(Out, Policy, (Pack ? "..." : "") + DeclName, Indentation);
288 }
289 
290 void DeclPrinter::ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls) {
291  this->Indent();
292  Decl::printGroup(Decls.data(), Decls.size(), Out, Policy, Indentation);
293  Out << ";\n";
294  Decls.clear();
295 
296 }
297 
298 void DeclPrinter::Print(AccessSpecifier AS) {
299  const auto AccessSpelling = getAccessSpelling(AS);
300  if (AccessSpelling.empty())
301  llvm_unreachable("No access specifier!");
302  Out << AccessSpelling;
303 }
304 
305 void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl,
306  std::string &Proto) {
307  bool HasInitializerList = false;
308  for (const auto *BMInitializer : CDecl->inits()) {
309  if (BMInitializer->isInClassMemberInitializer())
310  continue;
311 
312  if (!HasInitializerList) {
313  Proto += " : ";
314  Out << Proto;
315  Proto.clear();
316  HasInitializerList = true;
317  } else
318  Out << ", ";
319 
320  if (BMInitializer->isAnyMemberInitializer()) {
321  FieldDecl *FD = BMInitializer->getAnyMember();
322  Out << *FD;
323  } else {
324  Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
325  }
326 
327  Out << "(";
328  if (!BMInitializer->getInit()) {
329  // Nothing to print
330  } else {
331  Expr *Init = BMInitializer->getInit();
332  if (ExprWithCleanups *Tmp = dyn_cast<ExprWithCleanups>(Init))
333  Init = Tmp->getSubExpr();
334 
335  Init = Init->IgnoreParens();
336 
337  Expr *SimpleInit = nullptr;
338  Expr **Args = nullptr;
339  unsigned NumArgs = 0;
340  if (ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
341  Args = ParenList->getExprs();
342  NumArgs = ParenList->getNumExprs();
343  } else if (CXXConstructExpr *Construct =
344  dyn_cast<CXXConstructExpr>(Init)) {
345  Args = Construct->getArgs();
346  NumArgs = Construct->getNumArgs();
347  } else
348  SimpleInit = Init;
349 
350  if (SimpleInit)
351  SimpleInit->printPretty(Out, nullptr, Policy, Indentation, "\n",
352  &Context);
353  else {
354  for (unsigned I = 0; I != NumArgs; ++I) {
355  assert(Args[I] != nullptr && "Expected non-null Expr");
356  if (isa<CXXDefaultArgExpr>(Args[I]))
357  break;
358 
359  if (I)
360  Out << ", ";
361  Args[I]->printPretty(Out, nullptr, Policy, Indentation, "\n",
362  &Context);
363  }
364  }
365  }
366  Out << ")";
367  if (BMInitializer->isPackExpansion())
368  Out << "...";
369  }
370 }
371 
372 //----------------------------------------------------------------------------
373 // Common C declarations
374 //----------------------------------------------------------------------------
375 
376 void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
377  if (Policy.TerseOutput)
378  return;
379 
380  if (Indent)
381  Indentation += Policy.Indentation;
382 
383  SmallVector<Decl*, 2> Decls;
384  for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
385  D != DEnd; ++D) {
386 
387  // Don't print ObjCIvarDecls, as they are printed when visiting the
388  // containing ObjCInterfaceDecl.
389  if (isa<ObjCIvarDecl>(*D))
390  continue;
391 
392  // Skip over implicit declarations in pretty-printing mode.
393  if (D->isImplicit())
394  continue;
395 
396  // Don't print implicit specializations, as they are printed when visiting
397  // corresponding templates.
398  if (auto FD = dyn_cast<FunctionDecl>(*D))
399  if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation &&
400  !isa<ClassTemplateSpecializationDecl>(DC))
401  continue;
402 
403  // The next bits of code handle stuff like "struct {int x;} a,b"; we're
404  // forced to merge the declarations because there's no other way to
405  // refer to the struct in question. When that struct is named instead, we
406  // also need to merge to avoid splitting off a stand-alone struct
407  // declaration that produces the warning ext_no_declarators in some
408  // contexts.
409  //
410  // This limited merging is safe without a bunch of other checks because it
411  // only merges declarations directly referring to the tag, not typedefs.
412  //
413  // Check whether the current declaration should be grouped with a previous
414  // non-free-standing tag declaration.
415  QualType CurDeclType = getDeclType(*D);
416  if (!Decls.empty() && !CurDeclType.isNull()) {
417  QualType BaseType = GetBaseType(CurDeclType);
418  if (!BaseType.isNull() && isa<ElaboratedType>(BaseType) &&
419  cast<ElaboratedType>(BaseType)->getOwnedTagDecl() == Decls[0]) {
420  Decls.push_back(*D);
421  continue;
422  }
423  }
424 
425  // If we have a merged group waiting to be handled, handle it now.
426  if (!Decls.empty())
427  ProcessDeclGroup(Decls);
428 
429  // If the current declaration is not a free standing declaration, save it
430  // so we can merge it with the subsequent declaration(s) using it.
431  if (isa<TagDecl>(*D) && !cast<TagDecl>(*D)->isFreeStanding()) {
432  Decls.push_back(*D);
433  continue;
434  }
435 
436  if (isa<AccessSpecDecl>(*D)) {
437  Indentation -= Policy.Indentation;
438  this->Indent();
439  Print(D->getAccess());
440  Out << ":\n";
441  Indentation += Policy.Indentation;
442  continue;
443  }
444 
445  this->Indent();
446  Visit(*D);
447 
448  // FIXME: Need to be able to tell the DeclPrinter when
449  const char *Terminator = nullptr;
450  if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D) ||
451  isa<OMPDeclareMapperDecl>(*D) || isa<OMPRequiresDecl>(*D) ||
452  isa<OMPAllocateDecl>(*D))
453  Terminator = nullptr;
454  else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody())
455  Terminator = nullptr;
456  else if (auto FD = dyn_cast<FunctionDecl>(*D)) {
457  if (FD->isThisDeclarationADefinition())
458  Terminator = nullptr;
459  else
460  Terminator = ";";
461  } else if (auto TD = dyn_cast<FunctionTemplateDecl>(*D)) {
462  if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
463  Terminator = nullptr;
464  else
465  Terminator = ";";
469  Terminator = nullptr;
470  else if (isa<EnumConstantDecl>(*D)) {
472  ++Next;
473  if (Next != DEnd)
474  Terminator = ",";
475  } else
476  Terminator = ";";
477 
478  if (Terminator)
479  Out << Terminator;
480  if (!Policy.TerseOutput &&
481  ((isa<FunctionDecl>(*D) &&
482  cast<FunctionDecl>(*D)->doesThisDeclarationHaveABody()) ||
483  (isa<FunctionTemplateDecl>(*D) &&
484  cast<FunctionTemplateDecl>(*D)->getTemplatedDecl()->doesThisDeclarationHaveABody())))
485  ; // StmtPrinter already added '\n' after CompoundStmt.
486  else
487  Out << "\n";
488 
489  // Declare target attribute is special one, natural spelling for the pragma
490  // assumes "ending" construct so print it here.
491  if (D->hasAttr<OMPDeclareTargetDeclAttr>())
492  Out << "#pragma omp end declare target\n";
493  }
494 
495  if (!Decls.empty())
496  ProcessDeclGroup(Decls);
497 
498  if (Indent)
499  Indentation -= Policy.Indentation;
500 }
501 
502 void DeclPrinter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
503  VisitDeclContext(D, false);
504 }
505 
506 void DeclPrinter::VisitTypedefDecl(TypedefDecl *D) {
507  if (!Policy.SuppressSpecifiers) {
508  Out << "typedef ";
509 
510  if (D->isModulePrivate())
511  Out << "__module_private__ ";
512  }
513  QualType Ty = D->getTypeSourceInfo()->getType();
514  Ty.print(Out, Policy, D->getName(), Indentation);
515  prettyPrintAttributes(D);
516 }
517 
518 void DeclPrinter::VisitTypeAliasDecl(TypeAliasDecl *D) {
519  Out << "using " << *D;
520  prettyPrintAttributes(D);
521  Out << " = " << D->getTypeSourceInfo()->getType().getAsString(Policy);
522 }
523 
524 void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
525  if (!Policy.SuppressSpecifiers && D->isModulePrivate())
526  Out << "__module_private__ ";
527  Out << "enum";
528  if (D->isScoped()) {
529  if (D->isScopedUsingClassTag())
530  Out << " class";
531  else
532  Out << " struct";
533  }
534 
535  prettyPrintAttributes(D);
536 
537  if (D->getDeclName())
538  Out << ' ' << D->getDeclName();
539 
540  if (D->isFixed())
541  Out << " : " << D->getIntegerType().stream(Policy);
542 
543  if (D->isCompleteDefinition()) {
544  Out << " {\n";
545  VisitDeclContext(D);
546  Indent() << "}";
547  }
548 }
549 
550 void DeclPrinter::VisitRecordDecl(RecordDecl *D) {
551  if (!Policy.SuppressSpecifiers && D->isModulePrivate())
552  Out << "__module_private__ ";
553  Out << D->getKindName();
554 
555  prettyPrintAttributes(D);
556 
557  if (D->getIdentifier())
558  Out << ' ' << *D;
559 
560  if (D->isCompleteDefinition()) {
561  Out << " {\n";
562  VisitDeclContext(D);
563  Indent() << "}";
564  }
565 }
566 
567 void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
568  Out << *D;
569  prettyPrintAttributes(D);
570  if (Expr *Init = D->getInitExpr()) {
571  Out << " = ";
572  Init->printPretty(Out, nullptr, Policy, Indentation, "\n", &Context);
573  }
574 }
575 
576 static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out,
577  PrintingPolicy &Policy, unsigned Indentation,
578  const ASTContext &Context) {
579  std::string Proto = "explicit";
580  llvm::raw_string_ostream EOut(Proto);
581  if (ES.getExpr()) {
582  EOut << "(";
583  ES.getExpr()->printPretty(EOut, nullptr, Policy, Indentation, "\n",
584  &Context);
585  EOut << ")";
586  }
587  EOut << " ";
588  EOut.flush();
589  Out << Proto;
590 }
591 
592 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
593  if (!D->getDescribedFunctionTemplate() &&
595  prettyPrintPragmas(D);
596 
598  Out << "template<> ";
599  else if (!D->getDescribedFunctionTemplate()) {
600  for (unsigned I = 0, NumTemplateParams = D->getNumTemplateParameterLists();
601  I < NumTemplateParams; ++I)
602  printTemplateParameters(D->getTemplateParameterList(I));
603  }
604 
605  CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D);
606  CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D);
607  CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D);
608  if (!Policy.SuppressSpecifiers) {
609  switch (D->getStorageClass()) {
610  case SC_None: break;
611  case SC_Extern: Out << "extern "; break;
612  case SC_Static: Out << "static "; break;
613  case SC_PrivateExtern: Out << "__private_extern__ "; break;
614  case SC_Auto: case SC_Register:
615  llvm_unreachable("invalid for functions");
616  }
617 
618  if (D->isInlineSpecified()) Out << "inline ";
619  if (D->isVirtualAsWritten()) Out << "virtual ";
620  if (D->isModulePrivate()) Out << "__module_private__ ";
622  Out << "constexpr ";
623  if (D->isConsteval()) Out << "consteval ";
625  if (ExplicitSpec.isSpecified())
626  printExplicitSpecifier(ExplicitSpec, Out, Policy, Indentation, Context);
627  }
628 
629  PrintingPolicy SubPolicy(Policy);
630  SubPolicy.SuppressSpecifiers = false;
631  std::string Proto;
632 
633  if (Policy.FullyQualifiedName) {
634  Proto += D->getQualifiedNameAsString();
635  } else {
636  llvm::raw_string_ostream OS(Proto);
637  if (!Policy.SuppressScope) {
638  if (const NestedNameSpecifier *NS = D->getQualifier()) {
639  NS->print(OS, Policy);
640  }
641  }
642  D->getNameInfo().printName(OS, Policy);
643  }
644 
645  if (GuideDecl)
646  Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
648  llvm::raw_string_ostream POut(Proto);
649  DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
650  const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
651  if (TArgAsWritten && !Policy.PrintCanonicalTypes)
652  TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
653  else if (const TemplateArgumentList *TArgs =
655  TArgPrinter.printTemplateArguments(TArgs->asArray(), nullptr);
656  }
657 
658  QualType Ty = D->getType();
659  while (const ParenType *PT = dyn_cast<ParenType>(Ty)) {
660  Proto = '(' + Proto + ')';
661  Ty = PT->getInnerType();
662  }
663 
664  if (const FunctionType *AFT = Ty->getAs<FunctionType>()) {
665  const FunctionProtoType *FT = nullptr;
666  if (D->hasWrittenPrototype())
667  FT = dyn_cast<FunctionProtoType>(AFT);
668 
669  Proto += "(";
670  if (FT) {
671  llvm::raw_string_ostream POut(Proto);
672  DeclPrinter ParamPrinter(POut, SubPolicy, Context, Indentation);
673  for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
674  if (i) POut << ", ";
675  ParamPrinter.VisitParmVarDecl(D->getParamDecl(i));
676  }
677 
678  if (FT->isVariadic()) {
679  if (D->getNumParams()) POut << ", ";
680  POut << "...";
681  } else if (!D->getNumParams() && !Context.getLangOpts().CPlusPlus) {
682  // The function has a prototype, so it needs to retain the prototype
683  // in C.
684  POut << "void";
685  }
686  } else if (D->doesThisDeclarationHaveABody() && !D->hasPrototype()) {
687  for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
688  if (i)
689  Proto += ", ";
690  Proto += D->getParamDecl(i)->getNameAsString();
691  }
692  }
693 
694  Proto += ")";
695 
696  if (FT) {
697  if (FT->isConst())
698  Proto += " const";
699  if (FT->isVolatile())
700  Proto += " volatile";
701  if (FT->isRestrict())
702  Proto += " restrict";
703 
704  switch (FT->getRefQualifier()) {
705  case RQ_None:
706  break;
707  case RQ_LValue:
708  Proto += " &";
709  break;
710  case RQ_RValue:
711  Proto += " &&";
712  break;
713  }
714  }
715 
716  if (FT && FT->hasDynamicExceptionSpec()) {
717  Proto += " throw(";
718  if (FT->getExceptionSpecType() == EST_MSAny)
719  Proto += "...";
720  else
721  for (unsigned I = 0, N = FT->getNumExceptions(); I != N; ++I) {
722  if (I)
723  Proto += ", ";
724 
725  Proto += FT->getExceptionType(I).getAsString(SubPolicy);
726  }
727  Proto += ")";
728  } else if (FT && isNoexceptExceptionSpec(FT->getExceptionSpecType())) {
729  Proto += " noexcept";
731  Proto += "(";
732  llvm::raw_string_ostream EOut(Proto);
733  FT->getNoexceptExpr()->printPretty(EOut, nullptr, SubPolicy,
734  Indentation, "\n", &Context);
735  EOut.flush();
736  Proto += ")";
737  }
738  }
739 
740  if (CDecl) {
741  if (!Policy.TerseOutput)
742  PrintConstructorInitializers(CDecl, Proto);
743  } else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
744  if (FT && FT->hasTrailingReturn()) {
745  if (!GuideDecl)
746  Out << "auto ";
747  Out << Proto << " -> ";
748  Proto.clear();
749  }
750  AFT->getReturnType().print(Out, Policy, Proto);
751  Proto.clear();
752  }
753  Out << Proto;
754 
755  if (Expr *TrailingRequiresClause = D->getTrailingRequiresClause()) {
756  Out << " requires ";
757  TrailingRequiresClause->printPretty(Out, nullptr, SubPolicy, Indentation,
758  "\n", &Context);
759  }
760  } else {
761  Ty.print(Out, Policy, Proto);
762  }
763 
764  prettyPrintAttributes(D);
765 
766  if (D->isPure())
767  Out << " = 0";
768  else if (D->isDeletedAsWritten())
769  Out << " = delete";
770  else if (D->isExplicitlyDefaulted())
771  Out << " = default";
772  else if (D->doesThisDeclarationHaveABody()) {
773  if (!Policy.TerseOutput) {
774  if (!D->hasPrototype() && D->getNumParams()) {
775  // This is a K&R function definition, so we need to print the
776  // parameters.
777  Out << '\n';
778  DeclPrinter ParamPrinter(Out, SubPolicy, Context, Indentation);
779  Indentation += Policy.Indentation;
780  for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {
781  Indent();
782  ParamPrinter.VisitParmVarDecl(D->getParamDecl(i));
783  Out << ";\n";
784  }
785  Indentation -= Policy.Indentation;
786  }
787 
788  if (D->getBody())
789  D->getBody()->printPrettyControlled(Out, nullptr, SubPolicy, Indentation, "\n",
790  &Context);
791  } else {
792  if (!Policy.TerseOutput && isa<CXXConstructorDecl>(*D))
793  Out << " {}";
794  }
795  }
796 }
797 
798 void DeclPrinter::VisitFriendDecl(FriendDecl *D) {
799  if (TypeSourceInfo *TSI = D->getFriendType()) {
800  unsigned NumTPLists = D->getFriendTypeNumTemplateParameterLists();
801  for (unsigned i = 0; i < NumTPLists; ++i)
802  printTemplateParameters(D->getFriendTypeTemplateParameterList(i));
803  Out << "friend ";
804  Out << " " << TSI->getType().getAsString(Policy);
805  }
806  else if (FunctionDecl *FD =
807  dyn_cast<FunctionDecl>(D->getFriendDecl())) {
808  Out << "friend ";
809  VisitFunctionDecl(FD);
810  }
811  else if (FunctionTemplateDecl *FTD =
812  dyn_cast<FunctionTemplateDecl>(D->getFriendDecl())) {
813  Out << "friend ";
814  VisitFunctionTemplateDecl(FTD);
815  }
816  else if (ClassTemplateDecl *CTD =
817  dyn_cast<ClassTemplateDecl>(D->getFriendDecl())) {
818  Out << "friend ";
819  VisitRedeclarableTemplateDecl(CTD);
820  }
821 }
822 
823 void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
824  // FIXME: add printing of pragma attributes if required.
825  if (!Policy.SuppressSpecifiers && D->isMutable())
826  Out << "mutable ";
827  if (!Policy.SuppressSpecifiers && D->isModulePrivate())
828  Out << "__module_private__ ";
829 
831  stream(Policy, D->getName(), Indentation);
832 
833  if (D->isBitField()) {
834  Out << " : ";
835  D->getBitWidth()->printPretty(Out, nullptr, Policy, Indentation, "\n",
836  &Context);
837  }
838 
839  Expr *Init = D->getInClassInitializer();
840  if (!Policy.SuppressInitializers && Init) {
842  Out << " ";
843  else
844  Out << " = ";
845  Init->printPretty(Out, nullptr, Policy, Indentation, "\n", &Context);
846  }
847  prettyPrintAttributes(D);
848 }
849 
850 void DeclPrinter::VisitLabelDecl(LabelDecl *D) {
851  Out << *D << ":";
852 }
853 
854 void DeclPrinter::VisitVarDecl(VarDecl *D) {
855  prettyPrintPragmas(D);
856 
857  QualType T = D->getTypeSourceInfo()
858  ? D->getTypeSourceInfo()->getType()
860 
861  if (!Policy.SuppressSpecifiers) {
862  StorageClass SC = D->getStorageClass();
863  if (SC != SC_None)
864  Out << VarDecl::getStorageClassSpecifierString(SC) << " ";
865 
866  switch (D->getTSCSpec()) {
867  case TSCS_unspecified:
868  break;
869  case TSCS___thread:
870  Out << "__thread ";
871  break;
872  case TSCS__Thread_local:
873  Out << "_Thread_local ";
874  break;
875  case TSCS_thread_local:
876  Out << "thread_local ";
877  break;
878  }
879 
880  if (D->isModulePrivate())
881  Out << "__module_private__ ";
882 
883  if (D->isConstexpr()) {
884  Out << "constexpr ";
885  T.removeLocalConst();
886  }
887  }
888 
889  printDeclType(T, (isa<ParmVarDecl>(D) && Policy.CleanUglifiedParameters &&
890  D->getIdentifier())
891  ? D->getIdentifier()->deuglifiedName()
892  : D->getName());
893  Expr *Init = D->getInit();
894  if (!Policy.SuppressInitializers && Init) {
895  bool ImplicitInit = false;
896  if (D->isCXXForRangeDecl()) {
897  // FIXME: We should print the range expression instead.
898  ImplicitInit = true;
899  } else if (CXXConstructExpr *Construct =
900  dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
901  if (D->getInitStyle() == VarDecl::CallInit &&
902  !Construct->isListInitialization()) {
903  ImplicitInit = Construct->getNumArgs() == 0 ||
904  Construct->getArg(0)->isDefaultArgument();
905  }
906  }
907  if (!ImplicitInit) {
908  if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
909  Out << "(";
910  else if (D->getInitStyle() == VarDecl::CInit) {
911  Out << " = ";
912  }
913  PrintingPolicy SubPolicy(Policy);
914  SubPolicy.SuppressSpecifiers = false;
915  SubPolicy.IncludeTagDefinition = false;
916  Init->printPretty(Out, nullptr, SubPolicy, Indentation, "\n", &Context);
917  if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
918  Out << ")";
919  }
920  }
921  prettyPrintAttributes(D);
922 }
923 
924 void DeclPrinter::VisitParmVarDecl(ParmVarDecl *D) {
925  VisitVarDecl(D);
926 }
927 
928 void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
929  Out << "__asm (";
930  D->getAsmString()->printPretty(Out, nullptr, Policy, Indentation, "\n",
931  &Context);
932  Out << ")";
933 }
934 
935 void DeclPrinter::VisitImportDecl(ImportDecl *D) {
936  Out << "@import " << D->getImportedModule()->getFullModuleName()
937  << ";\n";
938 }
939 
940 void DeclPrinter::VisitStaticAssertDecl(StaticAssertDecl *D) {
941  Out << "static_assert(";
942  D->getAssertExpr()->printPretty(Out, nullptr, Policy, Indentation, "\n",
943  &Context);
944  if (StringLiteral *SL = D->getMessage()) {
945  Out << ", ";
946  SL->printPretty(Out, nullptr, Policy, Indentation, "\n", &Context);
947  }
948  Out << ")";
949 }
950 
951 //----------------------------------------------------------------------------
952 // C++ declarations
953 //----------------------------------------------------------------------------
954 void DeclPrinter::VisitNamespaceDecl(NamespaceDecl *D) {
955  if (D->isInline())
956  Out << "inline ";
957 
958  Out << "namespace ";
959  if (D->getDeclName())
960  Out << D->getDeclName() << ' ';
961  Out << "{\n";
962 
963  VisitDeclContext(D);
964  Indent() << "}";
965 }
966 
967 void DeclPrinter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
968  Out << "using namespace ";
969  if (D->getQualifier())
970  D->getQualifier()->print(Out, Policy);
971  Out << *D->getNominatedNamespaceAsWritten();
972 }
973 
974 void DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
975  Out << "namespace " << *D << " = ";
976  if (D->getQualifier())
977  D->getQualifier()->print(Out, Policy);
978  Out << *D->getAliasedNamespace();
979 }
980 
981 void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) {
982  prettyPrintAttributes(D);
983 }
984 
985 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
986  // FIXME: add printing of pragma attributes if required.
987  if (!Policy.SuppressSpecifiers && D->isModulePrivate())
988  Out << "__module_private__ ";
989  Out << D->getKindName();
990 
991  prettyPrintAttributes(D);
992 
993  if (D->getIdentifier()) {
994  Out << ' ' << *D;
995 
996  if (auto S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
997  ArrayRef<TemplateArgument> Args = S->getTemplateArgs().asArray();
998  if (!Policy.PrintCanonicalTypes)
999  if (const auto* TSI = S->getTypeAsWritten())
1000  if (const auto *TST =
1001  dyn_cast<TemplateSpecializationType>(TSI->getType()))
1002  Args = TST->template_arguments();
1003  printTemplateArguments(
1004  Args, S->getSpecializedTemplate()->getTemplateParameters());
1005  }
1006  }
1007 
1008  if (D->hasDefinition()) {
1009  if (D->hasAttr<FinalAttr>()) {
1010  Out << " final";
1011  }
1012  }
1013 
1014  if (D->isCompleteDefinition()) {
1015  // Print the base classes
1016  if (D->getNumBases()) {
1017  Out << " : ";
1018  for (CXXRecordDecl::base_class_iterator Base = D->bases_begin(),
1019  BaseEnd = D->bases_end(); Base != BaseEnd; ++Base) {
1020  if (Base != D->bases_begin())
1021  Out << ", ";
1022 
1023  if (Base->isVirtual())
1024  Out << "virtual ";
1025 
1026  AccessSpecifier AS = Base->getAccessSpecifierAsWritten();
1027  if (AS != AS_none) {
1028  Print(AS);
1029  Out << " ";
1030  }
1031  Out << Base->getType().getAsString(Policy);
1032 
1033  if (Base->isPackExpansion())
1034  Out << "...";
1035  }
1036  }
1037 
1038  // Print the class definition
1039  // FIXME: Doesn't print access specifiers, e.g., "public:"
1040  if (Policy.TerseOutput) {
1041  Out << " {}";
1042  } else {
1043  Out << " {\n";
1044  VisitDeclContext(D);
1045  Indent() << "}";
1046  }
1047  }
1048 }
1049 
1050 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
1051  const char *l;
1053  l = "C";
1054  else {
1055  assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
1056  "unknown language in linkage specification");
1057  l = "C++";
1058  }
1059 
1060  Out << "extern \"" << l << "\" ";
1061  if (D->hasBraces()) {
1062  Out << "{\n";
1063  VisitDeclContext(D);
1064  Indent() << "}";
1065  } else
1066  Visit(*D->decls_begin());
1067 }
1068 
1069 void DeclPrinter::printTemplateParameters(const TemplateParameterList *Params,
1070  bool OmitTemplateKW) {
1071  assert(Params);
1072 
1073  if (!OmitTemplateKW)
1074  Out << "template ";
1075  Out << '<';
1076 
1077  bool NeedComma = false;
1078  for (const Decl *Param : *Params) {
1079  if (Param->isImplicit())
1080  continue;
1081 
1082  if (NeedComma)
1083  Out << ", ";
1084  else
1085  NeedComma = true;
1086 
1087  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
1088  VisitTemplateTypeParmDecl(TTP);
1089  } else if (auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
1090  VisitNonTypeTemplateParmDecl(NTTP);
1091  } else if (auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1092  VisitTemplateDecl(TTPD);
1093  // FIXME: print the default argument, if present.
1094  }
1095  }
1096 
1097  Out << '>';
1098  if (!OmitTemplateKW)
1099  Out << ' ';
1100 }
1101 
1102 void DeclPrinter::printTemplateArguments(ArrayRef<TemplateArgument> Args,
1103  const TemplateParameterList *Params) {
1104  Out << "<";
1105  for (size_t I = 0, E = Args.size(); I < E; ++I) {
1106  if (I)
1107  Out << ", ";
1108  if (!Params)
1109  Args[I].print(Policy, Out, /*IncludeType*/ true);
1110  else
1111  Args[I].print(Policy, Out,
1112  TemplateParameterList::shouldIncludeTypeForArgument(
1113  Policy, Params, I));
1114  }
1115  Out << ">";
1116 }
1117 
1118 void DeclPrinter::printTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
1119  const TemplateParameterList *Params) {
1120  Out << "<";
1121  for (size_t I = 0, E = Args.size(); I < E; ++I) {
1122  if (I)
1123  Out << ", ";
1124  if (!Params)
1125  Args[I].getArgument().print(Policy, Out, /*IncludeType*/ true);
1126  else
1127  Args[I].getArgument().print(
1128  Policy, Out,
1129  TemplateParameterList::shouldIncludeTypeForArgument(Policy, Params,
1130  I));
1131  }
1132  Out << ">";
1133 }
1134 
1135 void DeclPrinter::VisitTemplateDecl(const TemplateDecl *D) {
1136  printTemplateParameters(D->getTemplateParameters());
1137 
1138  if (const TemplateTemplateParmDecl *TTP =
1139  dyn_cast<TemplateTemplateParmDecl>(D)) {
1140  Out << "class";
1141 
1142  if (TTP->isParameterPack())
1143  Out << " ...";
1144  else if (TTP->getDeclName())
1145  Out << ' ';
1146 
1147  if (TTP->getDeclName()) {
1148  if (Policy.CleanUglifiedParameters && TTP->getIdentifier())
1149  Out << TTP->getIdentifier()->deuglifiedName();
1150  else
1151  Out << TTP->getDeclName();
1152  }
1153  } else if (auto *TD = D->getTemplatedDecl())
1154  Visit(TD);
1155  else if (const auto *Concept = dyn_cast<ConceptDecl>(D)) {
1156  Out << "concept " << Concept->getName() << " = " ;
1157  Concept->getConstraintExpr()->printPretty(Out, nullptr, Policy, Indentation,
1158  "\n", &Context);
1159  }
1160 }
1161 
1162 void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
1163  prettyPrintPragmas(D->getTemplatedDecl());
1164  // Print any leading template parameter lists.
1165  if (const FunctionDecl *FD = D->getTemplatedDecl()) {
1166  for (unsigned I = 0, NumTemplateParams = FD->getNumTemplateParameterLists();
1167  I < NumTemplateParams; ++I)
1168  printTemplateParameters(FD->getTemplateParameterList(I));
1169  }
1170  VisitRedeclarableTemplateDecl(D);
1171  // Declare target attribute is special one, natural spelling for the pragma
1172  // assumes "ending" construct so print it here.
1173  if (D->getTemplatedDecl()->hasAttr<OMPDeclareTargetDeclAttr>())
1174  Out << "#pragma omp end declare target\n";
1175 
1176  // Never print "instantiations" for deduction guides (they don't really
1177  // have them).
1178  if (PrintInstantiation &&
1179  !isa<CXXDeductionGuideDecl>(D->getTemplatedDecl())) {
1180  FunctionDecl *PrevDecl = D->getTemplatedDecl();
1181  const FunctionDecl *Def;
1182  if (PrevDecl->isDefined(Def) && Def != PrevDecl)
1183  return;
1184  for (auto *I : D->specializations())
1185  if (I->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) {
1186  if (!PrevDecl->isThisDeclarationADefinition())
1187  Out << ";\n";
1188  Indent();
1189  prettyPrintPragmas(I);
1190  Visit(I);
1191  }
1192  }
1193 }
1194 
1195 void DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
1196  VisitRedeclarableTemplateDecl(D);
1197 
1198  if (PrintInstantiation) {
1199  for (auto *I : D->specializations())
1200  if (I->getSpecializationKind() == TSK_ImplicitInstantiation) {
1202  Out << ";";
1203  Out << "\n";
1204  Indent();
1205  Visit(I);
1206  }
1207  }
1208 }
1209 
1210 void DeclPrinter::VisitClassTemplateSpecializationDecl(
1212  Out << "template<> ";
1213  VisitCXXRecordDecl(D);
1214 }
1215 
1216 void DeclPrinter::VisitClassTemplatePartialSpecializationDecl(
1218  printTemplateParameters(D->getTemplateParameters());
1219  VisitCXXRecordDecl(D);
1220 }
1221 
1222 //----------------------------------------------------------------------------
1223 // Objective-C declarations
1224 //----------------------------------------------------------------------------
1225 
1226 void DeclPrinter::PrintObjCMethodType(ASTContext &Ctx,
1228  QualType T) {
1229  Out << '(';
1230  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
1231  Out << "in ";
1232  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Inout)
1233  Out << "inout ";
1234  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Out)
1235  Out << "out ";
1236  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Bycopy)
1237  Out << "bycopy ";
1238  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Byref)
1239  Out << "byref ";
1240  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway)
1241  Out << "oneway ";
1242  if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) {
1243  if (auto nullability = AttributedType::stripOuterNullability(T))
1244  Out << getNullabilitySpelling(*nullability, true) << ' ';
1245  }
1246 
1248  Out << ')';
1249 }
1250 
1251 void DeclPrinter::PrintObjCTypeParams(ObjCTypeParamList *Params) {
1252  Out << "<";
1253  unsigned First = true;
1254  for (auto *Param : *Params) {
1255  if (First) {
1256  First = false;
1257  } else {
1258  Out << ", ";
1259  }
1260 
1261  switch (Param->getVariance()) {
1263  break;
1264 
1266  Out << "__covariant ";
1267  break;
1268 
1270  Out << "__contravariant ";
1271  break;
1272  }
1273 
1274  Out << Param->getDeclName();
1275 
1276  if (Param->hasExplicitBound()) {
1277  Out << " : " << Param->getUnderlyingType().getAsString(Policy);
1278  }
1279  }
1280  Out << ">";
1281 }
1282 
1283 void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
1284  if (OMD->isInstanceMethod())
1285  Out << "- ";
1286  else
1287  Out << "+ ";
1288  if (!OMD->getReturnType().isNull()) {
1289  PrintObjCMethodType(OMD->getASTContext(), OMD->getObjCDeclQualifier(),
1290  OMD->getReturnType());
1291  }
1292 
1294  std::string::size_type pos, lastPos = 0;
1295  for (const auto *PI : OMD->parameters()) {
1296  // FIXME: selector is missing here!
1297  pos = name.find_first_of(':', lastPos);
1298  if (lastPos != 0)
1299  Out << " ";
1300  Out << name.substr(lastPos, pos - lastPos) << ':';
1301  PrintObjCMethodType(OMD->getASTContext(),
1302  PI->getObjCDeclQualifier(),
1303  PI->getType());
1304  Out << *PI;
1305  lastPos = pos + 1;
1306  }
1307 
1308  if (OMD->param_begin() == OMD->param_end())
1309  Out << name;
1310 
1311  if (OMD->isVariadic())
1312  Out << ", ...";
1313 
1314  prettyPrintAttributes(OMD);
1315 
1316  if (OMD->getBody() && !Policy.TerseOutput) {
1317  Out << ' ';
1318  OMD->getBody()->printPretty(Out, nullptr, Policy, Indentation, "\n",
1319  &Context);
1320  }
1321  else if (Policy.PolishForDeclaration)
1322  Out << ';';
1323 }
1324 
1325 void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) {
1326  std::string I = OID->getNameAsString();
1327  ObjCInterfaceDecl *SID = OID->getSuperClass();
1328 
1329  bool eolnOut = false;
1330  if (SID)
1331  Out << "@implementation " << I << " : " << *SID;
1332  else
1333  Out << "@implementation " << I;
1334 
1335  if (OID->ivar_size() > 0) {
1336  Out << "{\n";
1337  eolnOut = true;
1338  Indentation += Policy.Indentation;
1339  for (const auto *I : OID->ivars()) {
1340  Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1341  getAsString(Policy) << ' ' << *I << ";\n";
1342  }
1343  Indentation -= Policy.Indentation;
1344  Out << "}\n";
1345  }
1346  else if (SID || (OID->decls_begin() != OID->decls_end())) {
1347  Out << "\n";
1348  eolnOut = true;
1349  }
1350  VisitDeclContext(OID, false);
1351  if (!eolnOut)
1352  Out << "\n";
1353  Out << "@end";
1354 }
1355 
1356 void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
1357  std::string I = OID->getNameAsString();
1358  ObjCInterfaceDecl *SID = OID->getSuperClass();
1359 
1360  if (!OID->isThisDeclarationADefinition()) {
1361  Out << "@class " << I;
1362 
1363  if (auto TypeParams = OID->getTypeParamListAsWritten()) {
1364  PrintObjCTypeParams(TypeParams);
1365  }
1366 
1367  Out << ";";
1368  return;
1369  }
1370  bool eolnOut = false;
1371  Out << "@interface " << I;
1372 
1373  if (auto TypeParams = OID->getTypeParamListAsWritten()) {
1374  PrintObjCTypeParams(TypeParams);
1375  }
1376 
1377  if (SID)
1378  Out << " : " << QualType(OID->getSuperClassType(), 0).getAsString(Policy);
1379 
1380  // Protocols?
1381  const ObjCList<ObjCProtocolDecl> &Protocols = OID->getReferencedProtocols();
1382  if (!Protocols.empty()) {
1383  for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
1384  E = Protocols.end(); I != E; ++I)
1385  Out << (I == Protocols.begin() ? '<' : ',') << **I;
1386  Out << "> ";
1387  }
1388 
1389  if (OID->ivar_size() > 0) {
1390  Out << "{\n";
1391  eolnOut = true;
1392  Indentation += Policy.Indentation;
1393  for (const auto *I : OID->ivars()) {
1394  Indent() << I->getASTContext()
1395  .getUnqualifiedObjCPointerType(I->getType())
1396  .getAsString(Policy) << ' ' << *I << ";\n";
1397  }
1398  Indentation -= Policy.Indentation;
1399  Out << "}\n";
1400  }
1401  else if (SID || (OID->decls_begin() != OID->decls_end())) {
1402  Out << "\n";
1403  eolnOut = true;
1404  }
1405 
1406  VisitDeclContext(OID, false);
1407  if (!eolnOut)
1408  Out << "\n";
1409  Out << "@end";
1410  // FIXME: implement the rest...
1411 }
1412 
1413 void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
1414  if (!PID->isThisDeclarationADefinition()) {
1415  Out << "@protocol " << *PID << ";\n";
1416  return;
1417  }
1418  // Protocols?
1419  const ObjCList<ObjCProtocolDecl> &Protocols = PID->getReferencedProtocols();
1420  if (!Protocols.empty()) {
1421  Out << "@protocol " << *PID;
1422  for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
1423  E = Protocols.end(); I != E; ++I)
1424  Out << (I == Protocols.begin() ? '<' : ',') << **I;
1425  Out << ">\n";
1426  } else
1427  Out << "@protocol " << *PID << '\n';
1428  VisitDeclContext(PID, false);
1429  Out << "@end";
1430 }
1431 
1432 void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
1433  Out << "@implementation ";
1434  if (const auto *CID = PID->getClassInterface())
1435  Out << *CID;
1436  else
1437  Out << "<<error-type>>";
1438  Out << '(' << *PID << ")\n";
1439 
1440  VisitDeclContext(PID, false);
1441  Out << "@end";
1442  // FIXME: implement the rest...
1443 }
1444 
1445 void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) {
1446  Out << "@interface ";
1447  if (const auto *CID = PID->getClassInterface())
1448  Out << *CID;
1449  else
1450  Out << "<<error-type>>";
1451  if (auto TypeParams = PID->getTypeParamList()) {
1452  PrintObjCTypeParams(TypeParams);
1453  }
1454  Out << "(" << *PID << ")\n";
1455  if (PID->ivar_size() > 0) {
1456  Out << "{\n";
1457  Indentation += Policy.Indentation;
1458  for (const auto *I : PID->ivars())
1459  Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1460  getAsString(Policy) << ' ' << *I << ";\n";
1461  Indentation -= Policy.Indentation;
1462  Out << "}\n";
1463  }
1464 
1465  VisitDeclContext(PID, false);
1466  Out << "@end";
1467 
1468  // FIXME: implement the rest...
1469 }
1470 
1471 void DeclPrinter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID) {
1472  Out << "@compatibility_alias " << *AID
1473  << ' ' << *AID->getClassInterface() << ";\n";
1474 }
1475 
1476 /// PrintObjCPropertyDecl - print a property declaration.
1477 ///
1478 /// Print attributes in the following order:
1479 /// - class
1480 /// - nonatomic | atomic
1481 /// - assign | retain | strong | copy | weak | unsafe_unretained
1482 /// - readwrite | readonly
1483 /// - getter & setter
1484 /// - nullability
1485 void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
1487  Out << "@required\n";
1489  Out << "@optional\n";
1490 
1491  QualType T = PDecl->getType();
1492 
1493  Out << "@property";
1495  bool first = true;
1496  Out << "(";
1498  Out << (first ? "" : ", ") << "class";
1499  first = false;
1500  }
1501 
1503  Out << (first ? "" : ", ") << "direct";
1504  first = false;
1505  }
1506 
1507  if (PDecl->getPropertyAttributes() &
1509  Out << (first ? "" : ", ") << "nonatomic";
1510  first = false;
1511  }
1513  Out << (first ? "" : ", ") << "atomic";
1514  first = false;
1515  }
1516 
1518  Out << (first ? "" : ", ") << "assign";
1519  first = false;
1520  }
1522  Out << (first ? "" : ", ") << "retain";
1523  first = false;
1524  }
1525 
1527  Out << (first ? "" : ", ") << "strong";
1528  first = false;
1529  }
1531  Out << (first ? "" : ", ") << "copy";
1532  first = false;
1533  }
1535  Out << (first ? "" : ", ") << "weak";
1536  first = false;
1537  }
1538  if (PDecl->getPropertyAttributes() &
1540  Out << (first ? "" : ", ") << "unsafe_unretained";
1541  first = false;
1542  }
1543 
1544  if (PDecl->getPropertyAttributes() &
1546  Out << (first ? "" : ", ") << "readwrite";
1547  first = false;
1548  }
1550  Out << (first ? "" : ", ") << "readonly";
1551  first = false;
1552  }
1553 
1555  Out << (first ? "" : ", ") << "getter = ";
1556  PDecl->getGetterName().print(Out);
1557  first = false;
1558  }
1560  Out << (first ? "" : ", ") << "setter = ";
1561  PDecl->getSetterName().print(Out);
1562  first = false;
1563  }
1564 
1565  if (PDecl->getPropertyAttributes() &
1567  if (auto nullability = AttributedType::stripOuterNullability(T)) {
1568  if (*nullability == NullabilityKind::Unspecified &&
1569  (PDecl->getPropertyAttributes() &
1571  Out << (first ? "" : ", ") << "null_resettable";
1572  } else {
1573  Out << (first ? "" : ", ")
1574  << getNullabilitySpelling(*nullability, true);
1575  }
1576  first = false;
1577  }
1578  }
1579 
1580  (void) first; // Silence dead store warning due to idiomatic code.
1581  Out << ")";
1582  }
1585  Out << ' ' << TypeStr;
1586  if (!StringRef(TypeStr).endswith("*"))
1587  Out << ' ';
1588  Out << *PDecl;
1589  if (Policy.PolishForDeclaration)
1590  Out << ';';
1591 }
1592 
1593 void DeclPrinter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PID) {
1595  Out << "@synthesize ";
1596  else
1597  Out << "@dynamic ";
1598  Out << *PID->getPropertyDecl();
1599  if (PID->getPropertyIvarDecl())
1600  Out << '=' << *PID->getPropertyIvarDecl();
1601 }
1602 
1603 void DeclPrinter::VisitUsingDecl(UsingDecl *D) {
1604  if (!D->isAccessDeclaration())
1605  Out << "using ";
1606  if (D->hasTypename())
1607  Out << "typename ";
1608  D->getQualifier()->print(Out, Policy);
1609 
1610  // Use the correct record name when the using declaration is used for
1611  // inheriting constructors.
1612  for (const auto *Shadow : D->shadows()) {
1613  if (const auto *ConstructorShadow =
1614  dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1615  assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1616  Out << *ConstructorShadow->getNominatedBaseClass();
1617  return;
1618  }
1619  }
1620  Out << *D;
1621 }
1622 
1623 void DeclPrinter::VisitUsingEnumDecl(UsingEnumDecl *D) {
1624  Out << "using enum " << D->getEnumDecl();
1625 }
1626 
1627 void
1628 DeclPrinter::VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
1629  Out << "using typename ";
1630  D->getQualifier()->print(Out, Policy);
1631  Out << D->getDeclName();
1632 }
1633 
1634 void DeclPrinter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
1635  if (!D->isAccessDeclaration())
1636  Out << "using ";
1637  D->getQualifier()->print(Out, Policy);
1638  Out << D->getDeclName();
1639 }
1640 
1641 void DeclPrinter::VisitUsingShadowDecl(UsingShadowDecl *D) {
1642  // ignore
1643 }
1644 
1645 void DeclPrinter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
1646  Out << "#pragma omp threadprivate";
1647  if (!D->varlist_empty()) {
1649  E = D->varlist_end();
1650  I != E; ++I) {
1651  Out << (I == D->varlist_begin() ? '(' : ',');
1652  NamedDecl *ND = cast<DeclRefExpr>(*I)->getDecl();
1653  ND->printQualifiedName(Out);
1654  }
1655  Out << ")";
1656  }
1657 }
1658 
1659 void DeclPrinter::VisitHLSLBufferDecl(HLSLBufferDecl *D) {
1660  if (D->isCBuffer())
1661  Out << "cbuffer ";
1662  else
1663  Out << "tbuffer ";
1664 
1665  Out << *D;
1666 
1667  prettyPrintAttributes(D);
1668 
1669  Out << " {\n";
1670  VisitDeclContext(D);
1671  Indent() << "}";
1672 }
1673 
1674 void DeclPrinter::VisitOMPAllocateDecl(OMPAllocateDecl *D) {
1675  Out << "#pragma omp allocate";
1676  if (!D->varlist_empty()) {
1678  E = D->varlist_end();
1679  I != E; ++I) {
1680  Out << (I == D->varlist_begin() ? '(' : ',');
1681  NamedDecl *ND = cast<DeclRefExpr>(*I)->getDecl();
1682  ND->printQualifiedName(Out);
1683  }
1684  Out << ")";
1685  }
1686  if (!D->clauselist_empty()) {
1687  OMPClausePrinter Printer(Out, Policy);
1688  for (OMPClause *C : D->clauselists()) {
1689  Out << " ";
1690  Printer.Visit(C);
1691  }
1692  }
1693 }
1694 
1695 void DeclPrinter::VisitOMPRequiresDecl(OMPRequiresDecl *D) {
1696  Out << "#pragma omp requires ";
1697  if (!D->clauselist_empty()) {
1698  OMPClausePrinter Printer(Out, Policy);
1699  for (auto I = D->clauselist_begin(), E = D->clauselist_end(); I != E; ++I)
1700  Printer.Visit(*I);
1701  }
1702 }
1703 
1704 void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
1705  if (!D->isInvalidDecl()) {
1706  Out << "#pragma omp declare reduction (";
1708  const char *OpName =
1710  assert(OpName && "not an overloaded operator");
1711  Out << OpName;
1712  } else {
1713  assert(D->getDeclName().isIdentifier());
1714  D->printName(Out, Policy);
1715  }
1716  Out << " : ";
1717  D->getType().print(Out, Policy);
1718  Out << " : ";
1719  D->getCombiner()->printPretty(Out, nullptr, Policy, 0, "\n", &Context);
1720  Out << ")";
1721  if (auto *Init = D->getInitializer()) {
1722  Out << " initializer(";
1723  switch (D->getInitializerKind()) {
1725  Out << "omp_priv(";
1726  break;
1728  Out << "omp_priv = ";
1729  break;
1731  break;
1732  }
1733  Init->printPretty(Out, nullptr, Policy, 0, "\n", &Context);
1735  Out << ")";
1736  Out << ")";
1737  }
1738  }
1739 }
1740 
1741 void DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
1742  if (!D->isInvalidDecl()) {
1743  Out << "#pragma omp declare mapper (";
1744  D->printName(Out, Policy);
1745  Out << " : ";
1746  D->getType().print(Out, Policy);
1747  Out << " ";
1748  Out << D->getVarName();
1749  Out << ")";
1750  if (!D->clauselist_empty()) {
1751  OMPClausePrinter Printer(Out, Policy);
1752  for (auto *C : D->clauselists()) {
1753  Out << " ";
1754  Printer.Visit(C);
1755  }
1756  }
1757  }
1758 }
1759 
1760 void DeclPrinter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
1761  D->getInit()->printPretty(Out, nullptr, Policy, Indentation, "\n", &Context);
1762 }
1763 
1764 void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) {
1765  if (const TypeConstraint *TC = TTP->getTypeConstraint())
1766  TC->print(Out, Policy);
1767  else if (TTP->wasDeclaredWithTypename())
1768  Out << "typename";
1769  else
1770  Out << "class";
1771 
1772  if (TTP->isParameterPack())
1773  Out << " ...";
1774  else if (TTP->getDeclName())
1775  Out << ' ';
1776 
1777  if (TTP->getDeclName()) {
1778  if (Policy.CleanUglifiedParameters && TTP->getIdentifier())
1779  Out << TTP->getIdentifier()->deuglifiedName();
1780  else
1781  Out << TTP->getDeclName();
1782  }
1783 
1784  if (TTP->hasDefaultArgument()) {
1785  Out << " = ";
1786  Out << TTP->getDefaultArgument().getAsString(Policy);
1787  }
1788 }
1789 
1790 void DeclPrinter::VisitNonTypeTemplateParmDecl(
1791  const NonTypeTemplateParmDecl *NTTP) {
1792  StringRef Name;
1793  if (IdentifierInfo *II = NTTP->getIdentifier())
1794  Name =
1795  Policy.CleanUglifiedParameters ? II->deuglifiedName() : II->getName();
1796  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
1797 
1798  if (NTTP->hasDefaultArgument()) {
1799  Out << " = ";
1800  NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy, Indentation,
1801  "\n", &Context);
1802  }
1803 }
clang::ExplicitSpecifier
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1830
clang::TagDecl::getKindName
StringRef getKindName() const
Definition: Decl.h:3616
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1149
clang::OMPRequiresDecl::clauselist_empty
bool clauselist_empty() const
Definition: DeclOpenMP.h:439
clang::OMPAllocateDecl
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:473
clang::EmptyDecl
Represents an empty-declaration.
Definition: Decl.h:4714
clang::QualType::removeLocalConst
void removeLocalConst()
Definition: Type.h:6729
clang::ClassTemplateDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
Definition: DeclTemplate.h:2327
clang::OMPDeclareReductionDecl::getInitializer
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:239
clang::ObjCPropertyImplDecl::getPropertyIvarDecl
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2844
clang::FunctionDecl::doesThisDeclarationHaveABody
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2217
clang::ObjCCompatibleAliasDecl
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2741
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
clang::UsingDirectiveDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition: DeclCXX.h:2966
clang::TemplateParameterList::print
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
Definition: DeclPrinter.cpp:137
clang::DeclContext::decls_end
decl_iterator decls_end() const
Definition: DeclBase.h:2180
clang::FunctionProtoType::hasTrailingReturn
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:4365
clang::FunctionDecl::hasWrittenPrototype
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition: Decl.h:2332
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2436
clang::FunctionDecl::getNumParams
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition: Decl.cpp:3466
clang::FunctionProtoType::getExceptionSpecType
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition: Type.h:4252
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6604
clang::UsingDirectiveDecl::getNominatedNamespaceAsWritten
NamedDecl * getNominatedNamespaceAsWritten()
Definition: DeclCXX.h:2970
clang::OMPDeclareReductionDecl::CallInit
@ CallInit
Definition: DeclOpenMP.h:176
clang::FunctionType::isVolatile
bool isVolatile() const
Definition: Type.h:3959
clang::LinkageSpecDecl
Represents a linkage specification.
Definition: DeclCXX.h:2832
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::TemplateTypeParmDecl::getDefaultArgument
QualType getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1278
clang::CXXConversionDecl
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2766
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:560
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:3021
clang::ObjCPropertyAttribute::kind_direct
@ kind_direct
Definition: DeclObjCCommon.h:41
clang::ObjCImplementationDecl
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2566
clang::ClassTemplatePartialSpecializationDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:2158
clang::FunctionProtoType::hasDynamicExceptionSpec
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
Definition: Type.h:4261
clang::ObjCTypeParamVariance::Invariant
@ Invariant
The parameter is invariant: must match exactly.
clang::UsingDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3451
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2917
clang::ObjCPropertyAttribute::kind_class
@ kind_class
Definition: DeclObjCCommon.h:40
clang::OMPRequiresDecl::clauselist_end
clauselist_iterator clauselist_end()
Definition: DeclOpenMP.h:448
llvm::SmallVector
Definition: LLVM.h:38
clang::OMPThreadPrivateDecl
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
clang::Module::getFullModuleName
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Definition: Module.cpp:219
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::ParenListExpr
Definition: Expr.h:5542
clang::CXXDeductionGuideDecl::getDeducedTemplate
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
Definition: DeclCXX.h:1925
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::EnumDecl::isFixed
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3919
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1410
Attr.h
clang::FunctionDecl::getParamDecl
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2594
getDeclType
static QualType getDeclType(Decl *D)
Definition: DeclPrinter.cpp:179
clang::TypedefNameDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:3325
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::ObjCImplementationDecl::ivars
ivar_range ivars() const
Definition: DeclObjC.h:2715
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2930
clang::FieldDecl::getInClassInitializer
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition: Decl.h:3077
clang::UnresolvedUsingValueDecl::isAccessDeclaration
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3800
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1712
DeclCXX.h
clang::ObjCCategoryDecl::getClassInterface
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2339
Module.h
clang::UsingShadowDecl
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3222
clang::ObjCTypeParamVariance::Covariant
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
clang::ObjCPropertyImplDecl
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2771
clang::DeclContext::dumpDeclContext
void dumpDeclContext() const
Definition: DeclPrinter.cpp:219
clang::OMPAllocateDecl::clauselists
clauselist_range clauselists()
Definition: DeclOpenMP.h:526
clang::ComparisonCategoryType::First
@ First
clang::ObjCMethodDecl::param_end
param_const_iterator param_end() const
Definition: DeclObjC.h:361
clang::RQ_RValue
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
Definition: Type.h:1524
clang::QualType::getAsString
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Definition: Type.h:1088
clang::NonTypeTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1489
clang::OMPDeclareReductionDecl::CopyInit
@ CopyInit
Definition: DeclOpenMP.h:178
clang::ASTContext::getUnqualifiedObjCPointerType
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
Definition: ASTContext.h:2174
clang::FunctionDecl::getTemplateSpecializationArgs
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Definition: Decl.cpp:3932
clang::HLSLBufferDecl::isCBuffer
bool isCBuffer() const
Definition: Decl.h:4757
clang::TSCS_thread_local
@ TSCS_thread_local
C++11 thread_local.
Definition: Specifiers.h:229
clang::isComputedNoexcept
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:39
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2101
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::ObjCPropertyDecl::getPropertyImplementation
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:908
clang::FunctionDecl::isInlineSpecified
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2679
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3675
clang::QualType::stream
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: Type.h:1144
clang::ObjCPropertyDecl::Optional
@ Optional
Definition: DeclObjC.h:737
clang::OMPDeclareMapperDecl::clauselist_empty
bool clauselist_empty() const
Definition: DeclOpenMP.h:331
End
SourceLocation End
Definition: USRLocFinder.cpp:167
clang::ObjCPropertyAttribute::kind_strong
@ kind_strong
Definition: DeclObjCCommon.h:34
clang::ObjCImplDecl::getClassInterface
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2454
clang::FunctionDecl::isConsteval
bool isConsteval() const
Definition: Decl.h:2366
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3705
clang::FunctionProtoType::isVariadic
bool isVariadic() const
Whether this function prototype is variadic.
Definition: Type.h:4349
clang::FunctionDecl::hasPrototype
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Definition: Decl.h:2327
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1275
Decl.h
clang::FunctionDecl::isVirtualAsWritten
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2235
DeclObjC.h
clang::ObjCList::end
iterator end() const
Definition: DeclObjC.h:92
clang::IdentifierInfo::deuglifiedName
StringRef deuglifiedName() const
If the identifier is an "uglified" reserved name, return a cleaned form.
Definition: IdentifierTable.cpp:387
clang::AS_none
@ AS_none
Definition: Specifiers.h:115
clang::LinkageSpecDecl::lang_c
@ lang_c
Definition: DeclCXX.h:2841
clang::ObjCInterfaceDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1507
clang::OMPDeclareMapperDecl::getVarName
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Definition: DeclOpenMP.h:359
PrettyPrinter.h
clang::UsingDecl::isAccessDeclaration
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
Definition: DeclCXX.h:3460
clang::UnresolvedUsingTypenameDecl
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3858
clang::OMPAllocateDecl::varlist_empty
bool varlist_empty() const
Definition: DeclOpenMP.h:511
clang::ObjCPropertyAttribute::kind_atomic
@ kind_atomic
Definition: DeclObjCCommon.h:32
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:1006
clang::ObjCPropertyAttribute::kind_copy
@ kind_copy
Definition: DeclObjCCommon.h:29
clang::CXXConstructorDecl::inits
init_range inits()
Definition: DeclCXX.h:2529
clang::getAsString
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:55
clang::TranslationUnitDecl
The top declaration context.
Definition: Decl.h:80
clang::ObjCInterfaceDecl::ivar_size
unsigned ivar_size() const
Definition: DeclObjC.h:1453
DeclTemplate.h
clang::DeclarationName::getCXXOverloadedOperator
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Definition: DeclarationName.h:471
clang::ObjCTypeParamVariance::Contravariant
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
clang::PackExpansionType
Represents a pack expansion of types.
Definition: Type.h:5830
clang::OMPDeclareReductionDecl
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:171
clang::VarDecl::getStorageClassSpecifierString
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
Definition: Decl.cpp:2046
clang::DeclaratorDecl::getTemplateParameterList
TemplateParameterList * getTemplateParameterList(unsigned index) const
Definition: Decl.h:850
clang::ImportDecl
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4587
clang::Decl::getAccess
AccessSpecifier getAccess() const
Definition: DeclBase.h:491
clang::OMPThreadPrivateDecl::varlist_iterator
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: DeclOpenMP.h:138
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:2737
clang::OMPClause
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:55
clang::Decl::printGroup
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
Definition: DeclPrinter.cpp:187
clang::PrintingPolicy::SuppressSpecifiers
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
Definition: PrettyPrinter.h:108
clang::Decl::ObjCDeclQualifier
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:195
clang::AttributedType::stripOuterNullability
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Definition: Type.cpp:4300
clang::VectorType
Represents a GCC generic vector type.
Definition: Type.h:3358
clang::FieldDecl::getBitWidth
Expr * getBitWidth() const
Definition: Decl.h:3019
clang::ObjCPropertyImplDecl::Synthesize
@ Synthesize
Definition: DeclObjC.h:2774
clang::ObjCPropertyAttribute::kind_weak
@ kind_weak
Definition: DeclObjCCommon.h:33
clang::FunctionDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:2205
clang::SC_Extern
@ SC_Extern
Definition: Specifiers.h:239
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::ObjCPropertyAttribute::kind_unsafe_unretained
@ kind_unsafe_unretained
Definition: DeclObjCCommon.h:35
clang::FriendDecl::getFriendDecl
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:138
clang::ArrayType
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3012
clang::DeclarationName::getAsString
std::string getAsString() const
Retrieve the human-readable string for this name.
Definition: DeclarationName.cpp:235
clang::ObjCPropertyAttribute::kind_null_resettable
@ kind_null_resettable
Definition: DeclObjCCommon.h:39
clang::FunctionDecl::getBody
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3116
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7386
printExplicitSpecifier
static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out, PrintingPolicy &Policy, unsigned Indentation, const ASTContext &Context)
Definition: DeclPrinter.cpp:576
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:571
clang::ObjCInterfaceDecl::getReferencedProtocols
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:1318
clang::ObjCPropertyDecl::getSetterName
Selector getSetterName() const
Definition: DeclObjC.h:889
clang::ObjCMethodDecl::getSelector
Selector getSelector() const
Definition: DeclObjC.h:330
clang::DeclarationName::CXXOperatorName
@ CXXOperatorName
Definition: DeclarationName.h:215
clang::StaticAssertDecl::getMessage
StringLiteral * getMessage()
Definition: DeclCXX.h:3985
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
clang::LabelDecl
Represents the declaration of a label.
Definition: Decl.h:496
clang::ObjCInterfaceDecl::ivars
ivar_range ivars() const
Definition: DeclObjC.h:1435
clang::ClassTemplateDecl::specializations
spec_range specializations() const
Definition: DeclTemplate.h:2440
clang::DeclContext::decl_iterator
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:2135
clang::isa
bool isa(CodeGen::Address addr)
Definition: Address.h:177
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1998
clang::AutoType
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5246
clang::Selector::print
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
Definition: IdentifierTable.cpp:625
clang::BaseUsingDecl::shadows
shadow_range shadows() const
Definition: DeclCXX.h:3385
Expr.h
clang::FriendDecl
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:53
clang::ICIS_ListInit
@ ICIS_ListInit
Direct list-initialization.
Definition: Specifiers.h:262
ASTContext.h
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:906
clang::ObjCMethodDecl::getReturnType
QualType getReturnType() const
Definition: DeclObjC.h:332
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3423
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::OMPDeclareMapperDecl
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:286
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:70
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1776
clang::ExprWithCleanups
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3366
clang::ObjCCategoryImplDecl
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2513
clang::DeclaratorDecl::getTrailingRequiresClause
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:834
clang::NamedDecl::isModulePrivate
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:625
clang::DeclaratorDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Definition: Decl.h:816
clang::RQ_None
@ RQ_None
No ref-qualifier was provided.
Definition: Type.h:1518
clang::getOperatorSpelling
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
Definition: IdentifierTable.cpp:818
clang::OMPAllocateDecl::varlist_iterator
MutableArrayRef< Expr * >::iterator varlist_iterator
Definition: DeclOpenMP.h:501
clang::SC_Register
@ SC_Register
Definition: Specifiers.h:245
clang::ObjCPropertyAttribute::kind_readonly
@ kind_readonly
Definition: DeclObjCCommon.h:24
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3145
clang::ObjCInterfaceDecl::getTypeParamListAsWritten
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
Definition: DeclObjC.h:1288
ExprCXX.h
clang::ExplicitSpecifier::getFromDecl
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
Definition: DeclCXX.cpp:2086
Base
clang::EnumDecl::isScopedUsingClassTag
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3913
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3762
clang::ObjCPropertyDecl::getType
QualType getType() const
Definition: DeclObjC.h:800
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3528
clang::BlockPointerType
Pointer to a block type.
Definition: Type.h:2849
clang::FunctionProtoType::getRefQualifier
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Definition: Type.h:4375
clang::OMPDeclareReductionDecl::DirectInit
@ DirectInit
Definition: DeclOpenMP.h:177
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1205
clang::FunctionProtoType::getExceptionType
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
Definition: Type.h:4303
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
clang::ObjCImplementationDecl::getSuperClass
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2701
clang::FieldDecl::isMutable
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:3005
clang::SC_Static
@ SC_Static
Definition: Specifiers.h:240
clang::UsingDecl
Represents a C++ using-declaration.
Definition: DeclCXX.h:3414
clang::FunctionType::isRestrict
bool isRestrict() const
Definition: Type.h:3960
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2294
clang::NamespaceAliasDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Definition: DeclCXX.h:3089
clang::PrintingPolicy::IncludeTagDefinition
unsigned IncludeTagDefinition
When true, include the body of a tag definition.
Definition: PrettyPrinter.h:128
clang::OMPThreadPrivateDecl::varlist_empty
bool varlist_empty() const
Definition: DeclOpenMP.h:144
clang::OMPRequiresDecl::clauselist_begin
clauselist_iterator clauselist_begin()
Definition: DeclOpenMP.h:447
clang::ExplicitSpecifier::getExpr
const Expr * getExpr() const
Definition: DeclCXX.h:1839
clang::TemplateTypeParmDecl::wasDeclaredWithTypename
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
Definition: DeclTemplate.h:1267
GetBaseType
static QualType GetBaseType(QualType T)
Definition: DeclPrinter.cpp:149
clang::ObjCImplementationDecl::getNameAsString
std::string getNameAsString() const
Get the name of the class associated with this interface.
Definition: DeclObjC.h:2695
clang::ObjCMethodDecl::getObjCDeclQualifier
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:249
clang::AccessSpecifier
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:111
clang::StaticAssertDecl::getAssertExpr
Expr * getAssertExpr()
Definition: DeclCXX.h:3982
clang::ObjCObjectPointerType
Represents a pointer to an Objective C object.
Definition: Type.h:6270
clang::UsingEnumDecl
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3614
clang::HLSLBufferDecl
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:4729
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::FunctionDecl::getNameInfo
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:2104
clang::LinkageSpecDecl::getLanguage
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2861
clang::FunctionDecl::isConstexprSpecified
bool isConstexprSpecified() const
Definition: Decl.h:2363
clang::Indent
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Definition: JsonSupport.h:21
clang::DeclarationNameInfo::printName
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
Definition: DeclarationName.cpp:472
clang::UnresolvedUsingValueDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3807
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::FieldDecl::isBitField
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:3008
clang::EnumDecl::isScoped
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3910
clang::Decl::hasAttrs
bool hasAttrs() const
Definition: DeclBase.h:502
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1492
clang::TemplateTypeParmDecl::getTypeConstraint
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
Definition: DeclTemplate.h:1372
clang::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3959
clang::ObjCPropertyAttribute::kind_noattr
@ kind_noattr
Definition: DeclObjCCommon.h:23
clang::getNullabilitySpelling
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
Definition: IdentifierTable.cpp:832
clang::ExplicitSpecifier::isSpecified
bool isSpecified() const
Determine if the declaration had an explicit specifier of any kind.
Definition: DeclCXX.h:1843
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2273
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:701
clang::NullabilityKind::Unspecified
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
clang::VarDecl::getStorageClass
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1115
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4016
clang::OMPCapturedExprDecl
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:383
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1923
clang::ObjCCompatibleAliasDecl::getClassInterface
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2759
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:713
clang::FunctionDecl::getTemplateSpecializationArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Definition: Decl.cpp:3942
clang::ObjCInterfaceDecl::getSuperClassType
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1542
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:408
clang::DeclarationName::isIdentifier
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Definition: DeclarationName.h:384
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
llvm::ArrayRef< TemplateArgument >
DeclVisitor.h
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:4310
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::FunctionDecl::isPure
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2244
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:732
clang::LinkageSpecDecl::lang_cxx
@ lang_cxx
Definition: DeclCXX.h:2841
clang::ObjCMethodDecl::isInstanceMethod
bool isInstanceMethod() const
Definition: DeclObjC.h:431
clang::ObjCPropertyAttribute::kind_assign
@ kind_assign
Definition: DeclObjCCommon.h:26
clang::SC_PrivateExtern
@ SC_PrivateExtern
Definition: Specifiers.h:241
clang::Type::isSpecifierType
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
Definition: Type.cpp:2781
clang::EST_MSAny
@ EST_MSAny
Microsoft throw(...) extension.
Definition: ExceptionSpecificationType.h:24
clang::ObjCInterfaceDecl::getSuperClass
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:352
clang::Selector::getAsString
std::string getAsString() const
Derive the full selector name (e.g.
Definition: IdentifierTable.cpp:602
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:238
clang::NamedDecl::getQualifiedNameAsString
std::string getQualifiedNameAsString() const
Definition: Decl.cpp:1626
clang::ObjCPropertyImplDecl::getPropertyImplementation
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2840
clang::VarDecl::getInit
const Expr * getInit() const
Definition: Decl.h:1315
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::TypedefDecl
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3377
clang::OMPDeclareReductionDecl::getCombiner
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:221
clang::FriendDecl::getFriendTypeNumTemplateParameterLists
unsigned getFriendTypeNumTemplateParameterLists() const
Definition: DeclFriend.h:127
clang::ObjCPropertyImplDecl::getPropertyDecl
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2835
clang::FieldDecl::getInClassInitStyle
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Definition: Decl.h:3063
clang::NamedDecl::getNameAsString
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
Definition: Decl.h:290
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:699
clang::VarDecl::getTSCSpec
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:1124
clang::OMPThreadPrivateDecl::varlist_begin
varlist_iterator varlist_begin()
Definition: DeclOpenMP.h:152
clang::ObjCPropertyDecl::getGetterName
Selector getGetterName() const
Definition: DeclObjC.h:881
clang::ObjCMethodDecl::getBody
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:872
clang::OMPAllocateDecl::clauselist_empty
bool clauselist_empty() const
Definition: DeclOpenMP.h:513
clang::ObjCImplementationDecl::ivar_size
unsigned ivar_size() const
Definition: DeclObjC.h:2725
clang::VarDecl::isCXXForRangeDecl
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition: Decl.h:1462
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::PointerType
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2769
clang::UnresolvedUsingTypenameDecl::getQualifier
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3897
clang::LinkageSpecDecl::hasBraces
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition: DeclCXX.h:2870
clang::CXXDeductionGuideDecl
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1885
clang::ObjCMethodDecl::param_begin
param_const_iterator param_begin() const
Definition: DeclObjC.h:357
clang::ObjCPropertyAttribute::kind_readwrite
@ kind_readwrite
Definition: DeclObjCCommon.h:27
clang::OMPDeclareReductionDecl::getInitializerKind
InitKind getInitializerKind() const
Get initializer kind.
Definition: DeclOpenMP.h:242
clang::FileScopeAsmDecl
Definition: Decl.h:4248
clang::VarDecl::CInit
@ CInit
C-style initialization with assignment.
Definition: Decl.h:911
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:393
clang::ObjCTypeParamList
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:660
clang::OMPThreadPrivateDecl::varlist_end
varlist_iterator varlist_end()
Definition: DeclOpenMP.h:153
clang::TSCS__Thread_local
@ TSCS__Thread_local
C11 _Thread_local.
Definition: Specifiers.h:232
clang
Definition: CalledOnceCheck.h:17
clang::ObjCPropertyDecl::Required
@ Required
Definition: DeclObjC.h:737
clang::Expr::isDefaultArgument
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:3130
clang::FileScopeAsmDecl::getAsmString
const StringLiteral * getAsmString() const
Definition: Decl.h:4272
clang::ObjCListBase::empty
bool empty() const
Definition: DeclObjC.h:72
clang::NonTypeTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Definition: DeclTemplate.h:1524
clang::VarDecl::isConstexpr
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1509
clang::UsingDecl::hasTypename
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition: DeclCXX.h:3463
clang::Decl::print
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Definition: DeclPrinter.cpp:125
clang::ObjCPropertyAttribute::kind_nonatomic
@ kind_nonatomic
Definition: DeclObjCCommon.h:30
clang::DeclVisitor
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:66
clang::EnumDecl::getIntegerType
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition: Decl.h:3865
clang::ObjCProtocolDecl
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2050
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::OMPAllocateDecl::varlist_begin
varlist_iterator varlist_begin()
Definition: DeclOpenMP.h:521
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::OMPRequiresDecl
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:416
clang::RQ_LValue
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
Definition: Type.h:1521
clang::SC_Auto
@ SC_Auto
Definition: Specifiers.h:244
clang::ObjCCategoryDecl::getTypeParamList
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2344
clang::FunctionDecl::isExplicitlyDefaulted
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition: Decl.h:2273
clang::TSCS___thread
@ TSCS___thread
GNU __thread.
Definition: Specifiers.h:226
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3275
clang::Decl::getAttrs
AttrVec & getAttrs()
Definition: DeclBase.h:508
clang::NamedDecl::printName
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
Definition: Decl.cpp:1618
clang::DeclaratorDecl::getNumTemplateParameterLists
unsigned getNumTemplateParameterLists() const
Definition: Decl.h:846
clang::ObjCPropertyAttribute::kind_nullability
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Definition: DeclObjCCommon.h:38
clang::FunctionType::isConst
bool isConst() const
Definition: Type.h:3958
clang::ObjCMethodDecl::parameters
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:376
clang::ReferenceType
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2880
clang::ObjCPropertyAttribute::kind_getter
@ kind_getter
Definition: DeclObjCCommon.h:25
clang::getAccessSpelling
llvm::StringRef getAccessSpelling(AccessSpecifier AS)
Definition: Specifiers.h:383
clang::FunctionDecl::isFunctionTemplateSpecialization
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
Definition: Decl.h:2784
clang::QualType::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Definition: TypePrinter.cpp:2320
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::VarDecl::getInitStyle
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1406
clang::TypeAliasDecl
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3397
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:712
clang::SC_None
@ SC_None
Definition: Specifiers.h:238
clang::ImportDecl::getImportedModule
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4646
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::OMPClausePrinter
Definition: OpenMPClause.h:9040
clang::Stmt::printPrettyControlled
void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Definition: StmtPrinter.cpp:2744
clang::FunctionDecl::getDescribedFunctionTemplate
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition: Decl.cpp:3802
clang::transformer::name
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
Definition: RangeSelector.cpp:200
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:182
clang::OMPDeclareMapperDecl::clauselists
clauselist_range clauselists()
Definition: DeclOpenMP.h:333
clang::FunctionDecl::isDeletedAsWritten
bool isDeletedAsWritten() const
Definition: Decl.h:2413
clang::NamedDecl::printQualifiedName
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
Definition: Decl.cpp:1633
clang::ObjCProtocolDecl::getReferencedProtocols
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2118
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1829
clang::ObjCPropertyDecl::getPropertyAttributes
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition: DeclObjC.h:811
clang::OMPAllocateDecl::varlist_end
varlist_iterator varlist_end()
Definition: DeclOpenMP.h:522
clang::TSCS_unspecified
@ TSCS_unspecified
Definition: Specifiers.h:224
clang::FriendDecl::getFriendTypeTemplateParameterList
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition: DeclFriend.h:131
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:542
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1904
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3983
clang::ObjCList< ObjCProtocolDecl >
clang::ObjCProtocolDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2226
clang::FunctionDecl::getStorageClass
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2668
clang::NamespaceDecl::isInline
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:607
clang::TypeConstraint
Definition: ASTConcept.h:169
clang::CXXConstructExpr
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1467
clang::FunctionDecl::isDefined
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
Definition: Decl.cpp:3083
clang::ObjCPropertyAttribute::kind_retain
@ kind_retain
Definition: DeclObjCCommon.h:28
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:791
clang::DeclaratorDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:787
clang::ObjCList::begin
iterator begin() const
Definition: DeclObjC.h:91
clang::ObjCMethodDecl::isVariadic
bool isVariadic() const
Definition: DeclObjC.h:436
clang::ParenType
Sugar for parentheses used when specifying types.
Definition: Type.h:2743
clang::ento::ObjKind::OS
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
clang::FriendDecl::getFriendType
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:123
clang::UsingEnumDecl::getEnumDecl
EnumDecl * getEnumDecl() const
Definition: DeclCXX.h:3658
clang::VarDecl::CallInit
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:914
clang::ObjCPropertyAttribute::kind_setter
@ kind_setter
Definition: DeclObjCCommon.h:31
clang::FunctionProtoType::getNumExceptions
unsigned getNumExceptions() const
Return the number of types in the exception specification.
Definition: Type.h:4295
clang::isNoexceptExceptionSpec
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
Definition: ExceptionSpecificationType.h:44
clang::StorageClass
StorageClass
Storage classes.
Definition: Specifiers.h:236
clang::DeclContext::decls_begin
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1462
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274