clang  5.0.0
Decl.h
Go to the documentation of this file.
1 //===--- Decl.h - Classes for representing declarations ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the Decl subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_DECL_H
15 #define LLVM_CLANG_AST_DECL_H
16 
17 #include "clang/AST/APValue.h"
18 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/Redeclarable.h"
22 #include "clang/AST/Type.h"
23 #include "clang/Basic/Linkage.h"
24 #include "clang/Basic/Module.h"
27 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/ADT/Optional.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/raw_ostream.h"
31 #include "llvm/Support/TrailingObjects.h"
32 
33 namespace clang {
34 struct ASTTemplateArgumentListInfo;
35 class CXXTemporary;
36 class CompoundStmt;
37 class DependentFunctionTemplateSpecializationInfo;
38 class Expr;
39 class FunctionTemplateDecl;
40 class FunctionTemplateSpecializationInfo;
41 class LabelStmt;
42 class MemberSpecializationInfo;
43 class NestedNameSpecifier;
44 class ParmVarDecl;
45 class Stmt;
46 class StringLiteral;
47 class TemplateArgumentList;
48 class TemplateParameterList;
49 class TypeAliasTemplateDecl;
50 class TypeLoc;
51 class UnresolvedSetImpl;
52 class VarTemplateDecl;
53 
54 /// \brief A container of type source information.
55 ///
56 /// A client can read the relevant info using TypeLoc wrappers, e.g:
57 /// @code
58 /// TypeLoc TL = TypeSourceInfo->getTypeLoc();
59 /// TL.getStartLoc().print(OS, SrcMgr);
60 /// @endcode
61 ///
63  QualType Ty;
64  // Contains a memory block after the class, used for type source information,
65  // allocated by ASTContext.
66  friend class ASTContext;
67  TypeSourceInfo(QualType ty) : Ty(ty) { }
68 public:
69  /// \brief Return the type wrapped by this type source info.
70  QualType getType() const { return Ty; }
71 
72  /// \brief Return the TypeLoc wrapper for the type source info.
73  TypeLoc getTypeLoc() const; // implemented in TypeLoc.h
74 
75  /// \brief Override the type stored in this TypeSourceInfo. Use with caution!
76  void overrideType(QualType T) { Ty = T; }
77 };
78 
79 /// TranslationUnitDecl - The top declaration context.
80 class TranslationUnitDecl : public Decl, public DeclContext {
81  virtual void anchor();
82  ASTContext &Ctx;
83 
84  /// The (most recently entered) anonymous namespace for this
85  /// translation unit, if one has been created.
86  NamespaceDecl *AnonymousNamespace;
87 
88  explicit TranslationUnitDecl(ASTContext &ctx);
89 public:
90  ASTContext &getASTContext() const { return Ctx; }
91 
92  NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; }
93  void setAnonymousNamespace(NamespaceDecl *D) { AnonymousNamespace = D; }
94 
96  // Implement isa/cast/dyncast/etc.
97  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
98  static bool classofKind(Kind K) { return K == TranslationUnit; }
100  return static_cast<DeclContext *>(const_cast<TranslationUnitDecl*>(D));
101  }
103  return static_cast<TranslationUnitDecl *>(const_cast<DeclContext*>(DC));
104  }
105 };
106 
107 /// \brief Represents a `#pragma comment` line. Always a child of
108 /// TranslationUnitDecl.
109 class PragmaCommentDecl final
110  : public Decl,
111  private llvm::TrailingObjects<PragmaCommentDecl, char> {
112  virtual void anchor();
113 
114  PragmaMSCommentKind CommentKind;
115 
116  friend TrailingObjects;
117  friend class ASTDeclReader;
118  friend class ASTDeclWriter;
119 
121  PragmaMSCommentKind CommentKind)
122  : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
123 
124 public:
126  SourceLocation CommentLoc,
127  PragmaMSCommentKind CommentKind,
128  StringRef Arg);
130  unsigned ArgSize);
131 
132  PragmaMSCommentKind getCommentKind() const { return CommentKind; }
133 
134  StringRef getArg() const { return getTrailingObjects<char>(); }
135 
136  // Implement isa/cast/dyncast/etc.
137  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
138  static bool classofKind(Kind K) { return K == PragmaComment; }
139 };
140 
141 /// \brief Represents a `#pragma detect_mismatch` line. Always a child of
142 /// TranslationUnitDecl.
144  : public Decl,
145  private llvm::TrailingObjects<PragmaDetectMismatchDecl, char> {
146  virtual void anchor();
147 
148  size_t ValueStart;
149 
150  friend TrailingObjects;
151  friend class ASTDeclReader;
152  friend class ASTDeclWriter;
153 
155  size_t ValueStart)
156  : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
157 
158 public:
161  SourceLocation Loc, StringRef Name,
162  StringRef Value);
163  static PragmaDetectMismatchDecl *
164  CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize);
165 
166  StringRef getName() const { return getTrailingObjects<char>(); }
167  StringRef getValue() const { return getTrailingObjects<char>() + ValueStart; }
168 
169  // Implement isa/cast/dyncast/etc.
170  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
171  static bool classofKind(Kind K) { return K == PragmaDetectMismatch; }
172 };
173 
174 /// \brief Declaration context for names declared as extern "C" in C++. This
175 /// is neither the semantic nor lexical context for such declarations, but is
176 /// used to check for conflicts with other extern "C" declarations. Example:
177 ///
178 /// \code
179 /// namespace N { extern "C" void f(); } // #1
180 /// void N::f() {} // #2
181 /// namespace M { extern "C" void f(); } // #3
182 /// \endcode
183 ///
184 /// The semantic context of #1 is namespace N and its lexical context is the
185 /// LinkageSpecDecl; the semantic context of #2 is namespace N and its lexical
186 /// context is the TU. However, both declarations are also visible in the
187 /// extern "C" context.
188 ///
189 /// The declaration at #3 finds it is a redeclaration of \c N::f through
190 /// lookup in the extern "C" context.
191 class ExternCContextDecl : public Decl, public DeclContext {
192  virtual void anchor();
193 
195  : Decl(ExternCContext, TU, SourceLocation()),
196  DeclContext(ExternCContext) {}
197 public:
198  static ExternCContextDecl *Create(const ASTContext &C,
199  TranslationUnitDecl *TU);
200  // Implement isa/cast/dyncast/etc.
201  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
202  static bool classofKind(Kind K) { return K == ExternCContext; }
204  return static_cast<DeclContext *>(const_cast<ExternCContextDecl*>(D));
205  }
207  return static_cast<ExternCContextDecl *>(const_cast<DeclContext*>(DC));
208  }
209 };
210 
211 /// NamedDecl - This represents a decl with a name. Many decls have names such
212 /// as ObjCMethodDecl, but not \@class, etc.
213 class NamedDecl : public Decl {
214  virtual void anchor();
215  /// Name - The name of this declaration, which is typically a normal
216  /// identifier but may also be a special kind of name (C++
217  /// constructor, Objective-C selector, etc.)
218  DeclarationName Name;
219 
220 private:
221  NamedDecl *getUnderlyingDeclImpl() LLVM_READONLY;
222 
223 protected:
225  : Decl(DK, DC, L), Name(N) { }
226 
227 public:
228  /// getIdentifier - Get the identifier that names this declaration,
229  /// if there is one. This will return NULL if this declaration has
230  /// no name (e.g., for an unnamed class) or if the name is a special
231  /// name (C++ constructor, Objective-C selector, etc.).
233 
234  /// getName - Get the name of identifier for this declaration as a StringRef.
235  /// This requires that the declaration have a name and that it be a simple
236  /// identifier.
237  StringRef getName() const {
238  assert(Name.isIdentifier() && "Name is not a simple identifier");
239  return getIdentifier() ? getIdentifier()->getName() : "";
240  }
241 
242  /// getNameAsString - Get a human-readable name for the declaration, even if
243  /// it is one of the special kinds of names (C++ constructor, Objective-C
244  /// selector, etc). Creating this name requires expensive string
245  /// manipulation, so it should be called only when performance doesn't matter.
246  /// For simple declarations, getNameAsCString() should suffice.
247  //
248  // FIXME: This function should be renamed to indicate that it is not just an
249  // alternate form of getName(), and clients should move as appropriate.
250  //
251  // FIXME: Deprecated, move clients to getName().
252  std::string getNameAsString() const { return Name.getAsString(); }
253 
254  virtual void printName(raw_ostream &os) const;
255 
256  /// getDeclName - Get the actual, stored name of the declaration,
257  /// which may be a special name.
258  DeclarationName getDeclName() const { return Name; }
259 
260  /// \brief Set the name of this declaration.
261  void setDeclName(DeclarationName N) { Name = N; }
262 
263  /// printQualifiedName - Returns human-readable qualified name for
264  /// declaration, like A::B::i, for i being member of namespace A::B.
265  /// If declaration is not member of context which can be named (record,
266  /// namespace), it will return same result as printName().
267  /// Creating this name is expensive, so it should be called only when
268  /// performance doesn't matter.
269  void printQualifiedName(raw_ostream &OS) const;
270  void printQualifiedName(raw_ostream &OS, const PrintingPolicy &Policy) const;
271 
272  // FIXME: Remove string version.
273  std::string getQualifiedNameAsString() const;
274 
275  /// getNameForDiagnostic - Appends a human-readable name for this
276  /// declaration into the given stream.
277  ///
278  /// This is the method invoked by Sema when displaying a NamedDecl
279  /// in a diagnostic. It does not necessarily produce the same
280  /// result as printName(); for example, class template
281  /// specializations are printed with their template arguments.
282  virtual void getNameForDiagnostic(raw_ostream &OS,
283  const PrintingPolicy &Policy,
284  bool Qualified) const;
285 
286  /// \brief Determine whether this declaration, if
287  /// known to be well-formed within its context, will replace the
288  /// declaration OldD if introduced into scope. A declaration will
289  /// replace another declaration if, for example, it is a
290  /// redeclaration of the same variable or function, but not if it is
291  /// a declaration of a different kind (function vs. class) or an
292  /// overloaded function.
293  ///
294  /// \param IsKnownNewer \c true if this declaration is known to be newer
295  /// than \p OldD (for instance, if this declaration is newly-created).
296  bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const;
297 
298  /// \brief Determine whether this declaration has linkage.
299  bool hasLinkage() const;
300 
301  using Decl::isModulePrivate;
303 
304  /// \brief Determine whether this declaration is a C++ class member.
305  bool isCXXClassMember() const {
306  const DeclContext *DC = getDeclContext();
307 
308  // C++0x [class.mem]p1:
309  // The enumerators of an unscoped enumeration defined in
310  // the class are members of the class.
311  if (isa<EnumDecl>(DC))
312  DC = DC->getRedeclContext();
313 
314  return DC->isRecord();
315  }
316 
317  /// \brief Determine whether the given declaration is an instance member of
318  /// a C++ class.
319  bool isCXXInstanceMember() const;
320 
321  /// \brief Determine what kind of linkage this entity has.
322  /// This is not the linkage as defined by the standard or the codegen notion
323  /// of linkage. It is just an implementation detail that is used to compute
324  /// those.
325  Linkage getLinkageInternal() const;
326 
327  /// \brief Get the linkage from a semantic point of view. Entities in
328  /// anonymous namespaces are external (in c++98).
331  }
332 
333  /// \brief True if this decl has external linkage.
336  }
337 
338  bool isExternallyVisible() const {
340  }
341 
342  /// \brief Determines the visibility of this entity.
345  }
346 
347  /// \brief Determines the linkage and visibility of this entity.
349 
350  /// Kinds of explicit visibility.
354  };
355 
356  /// \brief If visibility was explicitly specified for this
357  /// declaration, return that visibility.
360 
361  /// \brief True if the computed linkage is valid. Used for consistency
362  /// checking. Should always return true.
363  bool isLinkageValid() const;
364 
365  /// \brief True if something has required us to compute the linkage
366  /// of this declaration.
367  ///
368  /// Language features which can retroactively change linkage (like a
369  /// typedef name for linkage purposes) may need to consider this,
370  /// but hopefully only in transitory ways during parsing.
371  bool hasLinkageBeenComputed() const {
372  return hasCachedLinkage();
373  }
374 
375  /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
376  /// the underlying named decl.
378  // Fast-path the common case.
379  if (this->getKind() != UsingShadow &&
380  this->getKind() != ConstructorUsingShadow &&
381  this->getKind() != ObjCCompatibleAlias &&
382  this->getKind() != NamespaceAlias)
383  return this;
384 
385  return getUnderlyingDeclImpl();
386  }
387  const NamedDecl *getUnderlyingDecl() const {
388  return const_cast<NamedDecl*>(this)->getUnderlyingDecl();
389  }
390 
392  return cast<NamedDecl>(static_cast<Decl *>(this)->getMostRecentDecl());
393  }
394  const NamedDecl *getMostRecentDecl() const {
395  return const_cast<NamedDecl*>(this)->getMostRecentDecl();
396  }
397 
399 
400  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
401  static bool classofKind(Kind K) { return K >= firstNamed && K <= lastNamed; }
402 };
403 
404 inline raw_ostream &operator<<(raw_ostream &OS, const NamedDecl &ND) {
405  ND.printName(OS);
406  return OS;
407 }
408 
409 /// LabelDecl - Represents the declaration of a label. Labels also have a
410 /// corresponding LabelStmt, which indicates the position that the label was
411 /// defined at. For normal labels, the location of the decl is the same as the
412 /// location of the statement. For GNU local labels (__label__), the decl
413 /// location is where the __label__ is.
414 class LabelDecl : public NamedDecl {
415  void anchor() override;
416  LabelStmt *TheStmt;
417  StringRef MSAsmName;
418  bool MSAsmNameResolved;
419  /// LocStart - For normal labels, this is the same as the main declaration
420  /// label, i.e., the location of the identifier; for GNU local labels,
421  /// this is the location of the __label__ keyword.
422  SourceLocation LocStart;
423 
425  LabelStmt *S, SourceLocation StartL)
426  : NamedDecl(Label, DC, IdentL, II),
427  TheStmt(S),
428  MSAsmNameResolved(false),
429  LocStart(StartL) {}
430 
431 public:
432  static LabelDecl *Create(ASTContext &C, DeclContext *DC,
433  SourceLocation IdentL, IdentifierInfo *II);
434  static LabelDecl *Create(ASTContext &C, DeclContext *DC,
435  SourceLocation IdentL, IdentifierInfo *II,
436  SourceLocation GnuLabelL);
437  static LabelDecl *CreateDeserialized(ASTContext &C, unsigned ID);
438 
439  LabelStmt *getStmt() const { return TheStmt; }
440  void setStmt(LabelStmt *T) { TheStmt = T; }
441 
442  bool isGnuLocal() const { return LocStart != getLocation(); }
443  void setLocStart(SourceLocation L) { LocStart = L; }
444 
445  SourceRange getSourceRange() const override LLVM_READONLY {
446  return SourceRange(LocStart, getLocation());
447  }
448 
449  bool isMSAsmLabel() const { return MSAsmName.size() != 0; }
450  bool isResolvedMSAsmLabel() const { return isMSAsmLabel() && MSAsmNameResolved; }
451  void setMSAsmLabel(StringRef Name);
452  StringRef getMSAsmLabel() const { return MSAsmName; }
453  void setMSAsmLabelResolved() { MSAsmNameResolved = true; }
454 
455  // Implement isa/cast/dyncast/etc.
456  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
457  static bool classofKind(Kind K) { return K == Label; }
458 };
459 
460 /// NamespaceDecl - Represent a C++ namespace.
461 class NamespaceDecl : public NamedDecl, public DeclContext,
462  public Redeclarable<NamespaceDecl>
463 {
464  /// LocStart - The starting location of the source range, pointing
465  /// to either the namespace or the inline keyword.
466  SourceLocation LocStart;
467  /// RBraceLoc - The ending location of the source range.
468  SourceLocation RBraceLoc;
469 
470  /// \brief A pointer to either the anonymous namespace that lives just inside
471  /// this namespace or to the first namespace in the chain (the latter case
472  /// only when this is not the first in the chain), along with a
473  /// boolean value indicating whether this is an inline namespace.
474  llvm::PointerIntPair<NamespaceDecl *, 1, bool> AnonOrFirstNamespaceAndInline;
475 
476  NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
477  SourceLocation StartLoc, SourceLocation IdLoc,
478  IdentifierInfo *Id, NamespaceDecl *PrevDecl);
479 
481  NamespaceDecl *getNextRedeclarationImpl() override;
482  NamespaceDecl *getPreviousDeclImpl() override;
483  NamespaceDecl *getMostRecentDeclImpl() override;
484 
485 public:
486  static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
487  bool Inline, SourceLocation StartLoc,
488  SourceLocation IdLoc, IdentifierInfo *Id,
489  NamespaceDecl *PrevDecl);
490 
491  static NamespaceDecl *CreateDeserialized(ASTContext &C, unsigned ID);
492 
494  typedef redeclarable_base::redecl_iterator redecl_iterator;
501 
502  /// \brief Returns true if this is an anonymous namespace declaration.
503  ///
504  /// For example:
505  /// \code
506  /// namespace {
507  /// ...
508  /// };
509  /// \endcode
510  /// q.v. C++ [namespace.unnamed]
511  bool isAnonymousNamespace() const {
512  return !getIdentifier();
513  }
514 
515  /// \brief Returns true if this is an inline namespace declaration.
516  bool isInline() const {
517  return AnonOrFirstNamespaceAndInline.getInt();
518  }
519 
520  /// \brief Set whether this is an inline namespace declaration.
521  void setInline(bool Inline) {
522  AnonOrFirstNamespaceAndInline.setInt(Inline);
523  }
524 
525  /// \brief Get the original (first) namespace declaration.
527 
528  /// \brief Get the original (first) namespace declaration.
529  const NamespaceDecl *getOriginalNamespace() const;
530 
531  /// \brief Return true if this declaration is an original (first) declaration
532  /// of the namespace. This is false for non-original (subsequent) namespace
533  /// declarations and anonymous namespaces.
534  bool isOriginalNamespace() const;
535 
536  /// \brief Retrieve the anonymous namespace nested inside this namespace,
537  /// if any.
539  return getOriginalNamespace()->AnonOrFirstNamespaceAndInline.getPointer();
540  }
541 
543  getOriginalNamespace()->AnonOrFirstNamespaceAndInline.setPointer(D);
544  }
545 
546  /// Retrieves the canonical declaration of this namespace.
548  return getOriginalNamespace();
549  }
551  return getOriginalNamespace();
552  }
553 
554  SourceRange getSourceRange() const override LLVM_READONLY {
555  return SourceRange(LocStart, RBraceLoc);
556  }
557 
558  SourceLocation getLocStart() const LLVM_READONLY { return LocStart; }
559  SourceLocation getRBraceLoc() const { return RBraceLoc; }
560  void setLocStart(SourceLocation L) { LocStart = L; }
561  void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
562 
563  // Implement isa/cast/dyncast/etc.
564  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
565  static bool classofKind(Kind K) { return K == Namespace; }
567  return static_cast<DeclContext *>(const_cast<NamespaceDecl*>(D));
568  }
570  return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
571  }
572 
573  friend class ASTDeclReader;
574  friend class ASTDeclWriter;
575 };
576 
577 /// ValueDecl - Represent the declaration of a variable (in which case it is
578 /// an lvalue) a function (in which case it is a function designator) or
579 /// an enum constant.
580 class ValueDecl : public NamedDecl {
581  void anchor() override;
582  QualType DeclType;
583 
584 protected:
587  : NamedDecl(DK, DC, L, N), DeclType(T) {}
588 public:
589  QualType getType() const { return DeclType; }
590  void setType(QualType newType) { DeclType = newType; }
591 
592  /// \brief Determine whether this symbol is weakly-imported,
593  /// or declared with the weak or weak-ref attr.
594  bool isWeak() const;
595 
596  // Implement isa/cast/dyncast/etc.
597  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
598  static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; }
599 };
600 
601 /// QualifierInfo - A struct with extended info about a syntactic
602 /// name qualifier, to be used for the case of out-of-line declarations.
605 
606  /// NumTemplParamLists - The number of "outer" template parameter lists.
607  /// The count includes all of the template parameter lists that were matched
608  /// against the template-ids occurring into the NNS and possibly (in the
609  /// case of an explicit specialization) a final "template <>".
611 
612  /// TemplParamLists - A new-allocated array of size NumTemplParamLists,
613  /// containing pointers to the "outer" template parameter lists.
614  /// It includes all of the template parameter lists that were matched
615  /// against the template-ids occurring into the NNS and possibly (in the
616  /// case of an explicit specialization) a final "template <>".
618 
619  /// Default constructor.
621  : QualifierLoc(), NumTemplParamLists(0), TemplParamLists(nullptr) {}
622 
623  /// setTemplateParameterListsInfo - Sets info about "outer" template
624  /// parameter lists.
627 
628 private:
629  // Copy constructor and copy assignment are disabled.
630  QualifierInfo(const QualifierInfo&) = delete;
631  QualifierInfo& operator=(const QualifierInfo&) = delete;
632 };
633 
634 /// \brief Represents a ValueDecl that came out of a declarator.
635 /// Contains type source information through TypeSourceInfo.
636 class DeclaratorDecl : public ValueDecl {
637  // A struct representing both a TInfo and a syntactic qualifier,
638  // to be used for the (uncommon) case of out-of-line declarations.
639  struct ExtInfo : public QualifierInfo {
640  TypeSourceInfo *TInfo;
641  };
642 
643  llvm::PointerUnion<TypeSourceInfo*, ExtInfo*> DeclInfo;
644 
645  /// InnerLocStart - The start of the source range for this declaration,
646  /// ignoring outer template declarations.
647  SourceLocation InnerLocStart;
648 
649  bool hasExtInfo() const { return DeclInfo.is<ExtInfo*>(); }
650  ExtInfo *getExtInfo() { return DeclInfo.get<ExtInfo*>(); }
651  const ExtInfo *getExtInfo() const { return DeclInfo.get<ExtInfo*>(); }
652 
653 protected:
656  SourceLocation StartL)
657  : ValueDecl(DK, DC, L, N, T), DeclInfo(TInfo), InnerLocStart(StartL) {
658  }
659 
660 public:
662  return hasExtInfo()
663  ? getExtInfo()->TInfo
664  : DeclInfo.get<TypeSourceInfo*>();
665  }
667  if (hasExtInfo())
668  getExtInfo()->TInfo = TI;
669  else
670  DeclInfo = TI;
671  }
672 
673  /// getInnerLocStart - Return SourceLocation representing start of source
674  /// range ignoring outer template declarations.
675  SourceLocation getInnerLocStart() const { return InnerLocStart; }
676  void setInnerLocStart(SourceLocation L) { InnerLocStart = L; }
677 
678  /// getOuterLocStart - Return SourceLocation representing start of source
679  /// range taking into account any outer template declarations.
681 
682  SourceRange getSourceRange() const override LLVM_READONLY;
683  SourceLocation getLocStart() const LLVM_READONLY {
684  return getOuterLocStart();
685  }
686 
687  /// \brief Retrieve the nested-name-specifier that qualifies the name of this
688  /// declaration, if it was present in the source.
690  return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
691  : nullptr;
692  }
693 
694  /// \brief Retrieve the nested-name-specifier (with source-location
695  /// information) that qualifies the name of this declaration, if it was
696  /// present in the source.
698  return hasExtInfo() ? getExtInfo()->QualifierLoc
700  }
701 
702  void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
703 
704  unsigned getNumTemplateParameterLists() const {
705  return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0;
706  }
708  assert(index < getNumTemplateParameterLists());
709  return getExtInfo()->TemplParamLists[index];
710  }
713 
715 
716  // Implement isa/cast/dyncast/etc.
717  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
718  static bool classofKind(Kind K) {
719  return K >= firstDeclarator && K <= lastDeclarator;
720  }
721 
722  friend class ASTDeclReader;
723  friend class ASTDeclWriter;
724 };
725 
726 /// \brief Structure used to store a statement, the constant value to
727 /// which it was evaluated (if any), and whether or not the statement
728 /// is an integral constant expression (if known).
732 
733  /// \brief Whether this statement was already evaluated.
734  bool WasEvaluated : 1;
735 
736  /// \brief Whether this statement is being evaluated.
737  bool IsEvaluating : 1;
738 
739  /// \brief Whether we already checked whether this statement was an
740  /// integral constant expression.
741  bool CheckedICE : 1;
742 
743  /// \brief Whether we are checking whether this statement is an
744  /// integral constant expression.
745  bool CheckingICE : 1;
746 
747  /// \brief Whether this statement is an integral constant expression,
748  /// or in C++11, whether the statement is a constant expression. Only
749  /// valid if CheckedICE is true.
750  bool IsICE : 1;
751 
754 };
755 
756 /// VarDecl - An instance of this class is created to represent a variable
757 /// declaration or definition.
758 class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
759 public:
760  /// getStorageClassSpecifierString - Return the string used to
761  /// specify the storage class \p SC.
762  ///
763  /// It is illegal to call this function with SC == None.
764  static const char *getStorageClassSpecifierString(StorageClass SC);
765 
766  /// \brief Initialization styles.
768  CInit, ///< C-style initialization with assignment
769  CallInit, ///< Call-style initialization (C++98)
770  ListInit ///< Direct list-initialization (C++11)
771  };
772 
773  /// \brief Kinds of thread-local storage.
774  enum TLSKind {
775  TLS_None, ///< Not a TLS variable.
776  TLS_Static, ///< TLS with a known-constant initializer.
777  TLS_Dynamic ///< TLS with a dynamic initializer.
778  };
779 
780 protected:
781  // A pointer union of Stmt * and EvaluatedStmt *. When an EvaluatedStmt, we
782  // have allocated the auxiliary struct of information there.
783  //
784  // TODO: It is a bit unfortunate to use a PointerUnion inside the VarDecl for
785  // this as *many* VarDecls are ParmVarDecls that don't have default
786  // arguments. We could save some space by moving this pointer union to be
787  // allocated in trailing space when necessary.
788  typedef llvm::PointerUnion<Stmt *, EvaluatedStmt *> InitType;
789 
790  /// \brief The initializer for this variable or, for a ParmVarDecl, the
791  /// C++ default argument.
792  mutable InitType Init;
793 
794 private:
795  class VarDeclBitfields {
796  friend class VarDecl;
797  friend class ASTDeclReader;
798 
799  unsigned SClass : 3;
800  unsigned TSCSpec : 2;
801  unsigned InitStyle : 2;
802  };
803  enum { NumVarDeclBits = 7 };
804 
805  friend class ASTDeclReader;
806  friend class StmtIteratorBase;
807  friend class ASTNodeImporter;
808 
809 protected:
810  enum { NumParameterIndexBits = 8 };
811 
817  };
818 
820  friend class ParmVarDecl;
821  friend class ASTDeclReader;
822 
823  unsigned : NumVarDeclBits;
824 
825  /// Whether this parameter inherits a default argument from a
826  /// prior declaration.
827  unsigned HasInheritedDefaultArg : 1;
828 
829  /// Describes the kind of default argument for this parameter. By default
830  /// this is none. If this is normal, then the default argument is stored in
831  /// the \c VarDecl initializer expression unless we were unable to parse
832  /// (even an invalid) expression for the default argument.
833  unsigned DefaultArgKind : 2;
834 
835  /// Whether this parameter undergoes K&R argument promotion.
836  unsigned IsKNRPromoted : 1;
837 
838  /// Whether this parameter is an ObjC method parameter or not.
839  unsigned IsObjCMethodParam : 1;
840 
841  /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
842  /// Otherwise, the number of function parameter scopes enclosing
843  /// the function parameter scope in which this parameter was
844  /// declared.
845  unsigned ScopeDepthOrObjCQuals : 7;
846 
847  /// The number of parameters preceding this parameter in the
848  /// function parameter scope in which it was declared.
849  unsigned ParameterIndex : NumParameterIndexBits;
850  };
851 
853  friend class VarDecl;
854  friend class ImplicitParamDecl;
855  friend class ASTDeclReader;
856 
857  unsigned : NumVarDeclBits;
858 
859  // FIXME: We need something similar to CXXRecordDecl::DefinitionData.
860  /// \brief Whether this variable is a definition which was demoted due to
861  /// module merge.
862  unsigned IsThisDeclarationADemotedDefinition : 1;
863 
864  /// \brief Whether this variable is the exception variable in a C++ catch
865  /// or an Objective-C @catch statement.
866  unsigned ExceptionVar : 1;
867 
868  /// \brief Whether this local variable could be allocated in the return
869  /// slot of its function, enabling the named return value optimization
870  /// (NRVO).
871  unsigned NRVOVariable : 1;
872 
873  /// \brief Whether this variable is the for-range-declaration in a C++0x
874  /// for-range statement.
875  unsigned CXXForRangeDecl : 1;
876 
877  /// \brief Whether this variable is an ARC pseudo-__strong
878  /// variable; see isARCPseudoStrong() for details.
879  unsigned ARCPseudoStrong : 1;
880 
881  /// \brief Whether this variable is (C++1z) inline.
882  unsigned IsInline : 1;
883 
884  /// \brief Whether this variable has (C++1z) inline explicitly specified.
885  unsigned IsInlineSpecified : 1;
886 
887  /// \brief Whether this variable is (C++0x) constexpr.
888  unsigned IsConstexpr : 1;
889 
890  /// \brief Whether this variable is the implicit variable for a lambda
891  /// init-capture.
892  unsigned IsInitCapture : 1;
893 
894  /// \brief Whether this local extern variable's previous declaration was
895  /// declared in the same block scope. This controls whether we should merge
896  /// the type of this declaration with its previous declaration.
897  unsigned PreviousDeclInSameBlockScope : 1;
898 
899  /// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or
900  /// something else.
901  unsigned ImplicitParamKind : 3;
902  };
903 
904  union {
905  unsigned AllBits;
906  VarDeclBitfields VarDeclBits;
909  };
910 
911  VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
912  SourceLocation IdLoc, IdentifierInfo *Id, QualType T,
913  TypeSourceInfo *TInfo, StorageClass SC);
914 
917  return getNextRedeclaration();
918  }
920  return getPreviousDecl();
921  }
923  return getMostRecentDecl();
924  }
925 
926 public:
928  typedef redeclarable_base::redecl_iterator redecl_iterator;
935 
936  static VarDecl *Create(ASTContext &C, DeclContext *DC,
937  SourceLocation StartLoc, SourceLocation IdLoc,
938  IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo,
939  StorageClass S);
940 
941  static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
942 
943  SourceRange getSourceRange() const override LLVM_READONLY;
944 
945  /// \brief Returns the storage class as written in the source. For the
946  /// computed linkage of symbol, see getLinkage.
948  return (StorageClass) VarDeclBits.SClass;
949  }
950  void setStorageClass(StorageClass SC);
951 
953  VarDeclBits.TSCSpec = TSC;
954  assert(VarDeclBits.TSCSpec == TSC && "truncation");
955  }
957  return static_cast<ThreadStorageClassSpecifier>(VarDeclBits.TSCSpec);
958  }
959  TLSKind getTLSKind() const;
960 
961  /// hasLocalStorage - Returns true if a variable with function scope
962  /// is a non-static local variable.
963  bool hasLocalStorage() const {
964  if (getStorageClass() == SC_None) {
965  // OpenCL v1.2 s6.5.3: The __constant or constant address space name is
966  // used to describe variables allocated in global memory and which are
967  // accessed inside a kernel(s) as read-only variables. As such, variables
968  // in constant address space cannot have local storage.
969  if (getType().getAddressSpace() == LangAS::opencl_constant)
970  return false;
971  // Second check is for C++11 [dcl.stc]p4.
972  return !isFileVarDecl() && getTSCSpec() == TSCS_unspecified;
973  }
974 
975  // Global Named Register (GNU extension)
977  return false;
978 
979  // Return true for: Auto, Register.
980  // Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal.
981 
982  return getStorageClass() >= SC_Auto;
983  }
984 
985  /// isStaticLocal - Returns true if a variable with function scope is a
986  /// static local variable.
987  bool isStaticLocal() const {
988  return (getStorageClass() == SC_Static ||
989  // C++11 [dcl.stc]p4
991  && !isFileVarDecl();
992  }
993 
994  /// \brief Returns true if a variable has extern or __private_extern__
995  /// storage.
996  bool hasExternalStorage() const {
997  return getStorageClass() == SC_Extern ||
999  }
1000 
1001  /// \brief Returns true for all variables that do not have local storage.
1002  ///
1003  /// This includes all global variables as well as static variables declared
1004  /// within a function.
1005  bool hasGlobalStorage() const { return !hasLocalStorage(); }
1006 
1007  /// \brief Get the storage duration of this variable, per C++ [basic.stc].
1009  return hasLocalStorage() ? SD_Automatic :
1011  }
1012 
1013  /// \brief Compute the language linkage.
1015 
1016  /// \brief Determines whether this variable is a variable with
1017  /// external, C linkage.
1018  bool isExternC() const;
1019 
1020  /// \brief Determines whether this variable's context is, or is nested within,
1021  /// a C++ extern "C" linkage spec.
1022  bool isInExternCContext() const;
1023 
1024  /// \brief Determines whether this variable's context is, or is nested within,
1025  /// a C++ extern "C++" linkage spec.
1026  bool isInExternCXXContext() const;
1027 
1028  /// isLocalVarDecl - Returns true for local variable declarations
1029  /// other than parameters. Note that this includes static variables
1030  /// inside of functions. It also includes variables inside blocks.
1031  ///
1032  /// void foo() { int x; static int y; extern int z; }
1033  ///
1034  bool isLocalVarDecl() const {
1035  if (getKind() != Decl::Var && getKind() != Decl::Decomposition)
1036  return false;
1037  if (const DeclContext *DC = getLexicalDeclContext())
1038  return DC->getRedeclContext()->isFunctionOrMethod();
1039  return false;
1040  }
1041 
1042  /// \brief Similar to isLocalVarDecl but also includes parameters.
1043  bool isLocalVarDeclOrParm() const {
1044  return isLocalVarDecl() || getKind() == Decl::ParmVar;
1045  }
1046 
1047  /// isFunctionOrMethodVarDecl - Similar to isLocalVarDecl, but
1048  /// excludes variables declared in blocks.
1050  if (getKind() != Decl::Var && getKind() != Decl::Decomposition)
1051  return false;
1053  return DC->isFunctionOrMethod() && DC->getDeclKind() != Decl::Block;
1054  }
1055 
1056  /// \brief Determines whether this is a static data member.
1057  ///
1058  /// This will only be true in C++, and applies to, e.g., the
1059  /// variable 'x' in:
1060  /// \code
1061  /// struct S {
1062  /// static int x;
1063  /// };
1064  /// \endcode
1065  bool isStaticDataMember() const {
1066  // If it wasn't static, it would be a FieldDecl.
1067  return getKind() != Decl::ParmVar && getDeclContext()->isRecord();
1068  }
1069 
1070  VarDecl *getCanonicalDecl() override;
1071  const VarDecl *getCanonicalDecl() const {
1072  return const_cast<VarDecl*>(this)->getCanonicalDecl();
1073  }
1074 
1076  DeclarationOnly, ///< This declaration is only a declaration.
1077  TentativeDefinition, ///< This declaration is a tentative definition.
1078  Definition ///< This declaration is definitely a definition.
1079  };
1080 
1081  /// \brief Check whether this declaration is a definition. If this could be
1082  /// a tentative definition (in C), don't check whether there's an overriding
1083  /// definition.
1087  }
1088 
1089  /// \brief Check whether this variable is defined in this
1090  /// translation unit.
1093  return hasDefinition(getASTContext());
1094  }
1095 
1096  /// \brief Get the tentative definition that acts as the real definition in
1097  /// a TU. Returns null if there is a proper definition available.
1099  const VarDecl *getActingDefinition() const {
1100  return const_cast<VarDecl*>(this)->getActingDefinition();
1101  }
1102 
1103  /// \brief Get the real (not just tentative) definition for this declaration.
1105  const VarDecl *getDefinition(ASTContext &C) const {
1106  return const_cast<VarDecl*>(this)->getDefinition(C);
1107  }
1109  return getDefinition(getASTContext());
1110  }
1111  const VarDecl *getDefinition() const {
1112  return const_cast<VarDecl*>(this)->getDefinition();
1113  }
1114 
1115  /// \brief Determine whether this is or was instantiated from an out-of-line
1116  /// definition of a static data member.
1117  bool isOutOfLine() const override;
1118 
1119  /// isFileVarDecl - Returns true for file scoped variable declaration.
1120  bool isFileVarDecl() const {
1121  Kind K = getKind();
1122  if (K == ParmVar || K == ImplicitParam)
1123  return false;
1124 
1125  if (getLexicalDeclContext()->getRedeclContext()->isFileContext())
1126  return true;
1127 
1128  if (isStaticDataMember())
1129  return true;
1130 
1131  return false;
1132  }
1133 
1134  /// getAnyInitializer - Get the initializer for this variable, no matter which
1135  /// declaration it is attached to.
1136  const Expr *getAnyInitializer() const {
1137  const VarDecl *D;
1138  return getAnyInitializer(D);
1139  }
1140 
1141  /// getAnyInitializer - Get the initializer for this variable, no matter which
1142  /// declaration it is attached to. Also get that declaration.
1143  const Expr *getAnyInitializer(const VarDecl *&D) const;
1144 
1145  bool hasInit() const;
1146  const Expr *getInit() const {
1147  return const_cast<VarDecl *>(this)->getInit();
1148  }
1149  Expr *getInit();
1150 
1151  /// \brief Retrieve the address of the initializer expression.
1152  Stmt **getInitAddress();
1153 
1154  void setInit(Expr *I);
1155 
1156  /// \brief Determine whether this variable's value can be used in a
1157  /// constant expression, according to the relevant language standard.
1158  /// This only checks properties of the declaration, and does not check
1159  /// whether the initializer is in fact a constant expression.
1161 
1163 
1164  /// \brief Attempt to evaluate the value of the initializer attached to this
1165  /// declaration, and produce notes explaining why it cannot be evaluated or is
1166  /// not a constant expression. Returns a pointer to the value if evaluation
1167  /// succeeded, 0 otherwise.
1168  APValue *evaluateValue() const;
1170 
1171  /// \brief Return the already-evaluated value of this variable's
1172  /// initializer, or NULL if the value is not yet known. Returns pointer
1173  /// to untyped APValue if the value could not be evaluated.
1174  APValue *getEvaluatedValue() const;
1175 
1176  /// \brief Determines whether it is already known whether the
1177  /// initializer is an integral constant expression or not.
1178  bool isInitKnownICE() const;
1179 
1180  /// \brief Determines whether the initializer is an integral constant
1181  /// expression, or in C++11, whether the initializer is a constant
1182  /// expression.
1183  ///
1184  /// \pre isInitKnownICE()
1185  bool isInitICE() const;
1186 
1187  /// \brief Determine whether the value of the initializer attached to this
1188  /// declaration is an integral constant expression.
1189  bool checkInitIsICE() const;
1190 
1192  VarDeclBits.InitStyle = Style;
1193  }
1194 
1195  /// \brief The style of initialization for this declaration.
1196  ///
1197  /// C-style initialization is "int x = 1;". Call-style initialization is
1198  /// a C++98 direct-initializer, e.g. "int x(1);". The Init expression will be
1199  /// the expression inside the parens or a "ClassType(a,b,c)" class constructor
1200  /// expression for class types. List-style initialization is C++11 syntax,
1201  /// e.g. "int x{1};". Clients can distinguish between different forms of
1202  /// initialization by checking this value. In particular, "int x = {1};" is
1203  /// C-style, "int x({1})" is call-style, and "int x{1};" is list-style; the
1204  /// Init expression in all three cases is an InitListExpr.
1206  return static_cast<InitializationStyle>(VarDeclBits.InitStyle);
1207  }
1208  /// \brief Whether the initializer is a direct-initializer (list or call).
1209  bool isDirectInit() const {
1210  return getInitStyle() != CInit;
1211  }
1212 
1213  /// \brief If this definition should pretend to be a declaration.
1215  return isa<ParmVarDecl>(this) ? false :
1216  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
1217  }
1218 
1219  /// \brief This is a definition which should be demoted to a declaration.
1220  ///
1221  /// In some cases (mostly module merging) we can end up with two visible
1222  /// definitions one of which needs to be demoted to a declaration to keep
1223  /// the AST invariants.
1225  assert (isThisDeclarationADefinition() && "Not a definition!");
1226  assert (!isa<ParmVarDecl>(this) && "Cannot demote ParmVarDecls!");
1227  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
1228  }
1229 
1230  /// \brief Determine whether this variable is the exception variable in a
1231  /// C++ catch statememt or an Objective-C \@catch statement.
1232  bool isExceptionVariable() const {
1233  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.ExceptionVar;
1234  }
1235  void setExceptionVariable(bool EV) {
1236  assert(!isa<ParmVarDecl>(this));
1237  NonParmVarDeclBits.ExceptionVar = EV;
1238  }
1239 
1240  /// \brief Determine whether this local variable can be used with the named
1241  /// return value optimization (NRVO).
1242  ///
1243  /// The named return value optimization (NRVO) works by marking certain
1244  /// non-volatile local variables of class type as NRVO objects. These
1245  /// locals can be allocated within the return slot of their containing
1246  /// function, in which case there is no need to copy the object to the
1247  /// return slot when returning from the function. Within the function body,
1248  /// each return that returns the NRVO object will have this variable as its
1249  /// NRVO candidate.
1250  bool isNRVOVariable() const {
1251  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.NRVOVariable;
1252  }
1253  void setNRVOVariable(bool NRVO) {
1254  assert(!isa<ParmVarDecl>(this));
1255  NonParmVarDeclBits.NRVOVariable = NRVO;
1256  }
1257 
1258  /// \brief Determine whether this variable is the for-range-declaration in
1259  /// a C++0x for-range statement.
1260  bool isCXXForRangeDecl() const {
1261  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.CXXForRangeDecl;
1262  }
1263  void setCXXForRangeDecl(bool FRD) {
1264  assert(!isa<ParmVarDecl>(this));
1265  NonParmVarDeclBits.CXXForRangeDecl = FRD;
1266  }
1267 
1268  /// \brief Determine whether this variable is an ARC pseudo-__strong
1269  /// variable. A pseudo-__strong variable has a __strong-qualified
1270  /// type but does not actually retain the object written into it.
1271  /// Generally such variables are also 'const' for safety.
1272  bool isARCPseudoStrong() const {
1273  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.ARCPseudoStrong;
1274  }
1275  void setARCPseudoStrong(bool ps) {
1276  assert(!isa<ParmVarDecl>(this));
1277  NonParmVarDeclBits.ARCPseudoStrong = ps;
1278  }
1279 
1280  /// Whether this variable is (C++1z) inline.
1281  bool isInline() const {
1282  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInline;
1283  }
1284  bool isInlineSpecified() const {
1285  return isa<ParmVarDecl>(this) ? false
1286  : NonParmVarDeclBits.IsInlineSpecified;
1287  }
1289  assert(!isa<ParmVarDecl>(this));
1290  NonParmVarDeclBits.IsInline = true;
1291  NonParmVarDeclBits.IsInlineSpecified = true;
1292  }
1294  assert(!isa<ParmVarDecl>(this));
1295  NonParmVarDeclBits.IsInline = true;
1296  }
1297 
1298  /// Whether this variable is (C++11) constexpr.
1299  bool isConstexpr() const {
1300  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsConstexpr;
1301  }
1302  void setConstexpr(bool IC) {
1303  assert(!isa<ParmVarDecl>(this));
1304  NonParmVarDeclBits.IsConstexpr = IC;
1305  }
1306 
1307  /// Whether this variable is the implicit variable for a lambda init-capture.
1308  bool isInitCapture() const {
1309  return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInitCapture;
1310  }
1311  void setInitCapture(bool IC) {
1312  assert(!isa<ParmVarDecl>(this));
1313  NonParmVarDeclBits.IsInitCapture = IC;
1314  }
1315 
1316  /// Whether this local extern variable declaration's previous declaration
1317  /// was declared in the same block scope. Only correct in C++.
1319  return isa<ParmVarDecl>(this)
1320  ? false
1321  : NonParmVarDeclBits.PreviousDeclInSameBlockScope;
1322  }
1324  assert(!isa<ParmVarDecl>(this));
1325  NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
1326  }
1327 
1328  /// \brief Retrieve the variable declaration from which this variable could
1329  /// be instantiated, if it is an instantiation (rather than a non-template).
1331 
1332  /// \brief If this variable is an instantiated static data member of a
1333  /// class template specialization, returns the templated static data member
1334  /// from which it was instantiated.
1336 
1337  /// \brief If this variable is an instantiation of a variable template or a
1338  /// static data member of a class template, determine what kind of
1339  /// template specialization or instantiation this is.
1341 
1342  /// \brief If this variable is an instantiation of a variable template or a
1343  /// static data member of a class template, determine its point of
1344  /// instantiation.
1346 
1347  /// \brief If this variable is an instantiation of a static data member of a
1348  /// class template specialization, retrieves the member specialization
1349  /// information.
1351 
1352  /// \brief For a static data member that was instantiated from a static
1353  /// data member of a class template, set the template specialiation kind.
1355  SourceLocation PointOfInstantiation = SourceLocation());
1356 
1357  /// \brief Specify that this variable is an instantiation of the
1358  /// static data member VD.
1361 
1362  /// \brief Retrieves the variable template that is described by this
1363  /// variable declaration.
1364  ///
1365  /// Every variable template is represented as a VarTemplateDecl and a
1366  /// VarDecl. The former contains template properties (such as
1367  /// the template parameter lists) while the latter contains the
1368  /// actual description of the template's
1369  /// contents. VarTemplateDecl::getTemplatedDecl() retrieves the
1370  /// VarDecl that from a VarTemplateDecl, while
1371  /// getDescribedVarTemplate() retrieves the VarTemplateDecl from
1372  /// a VarDecl.
1374 
1375  void setDescribedVarTemplate(VarTemplateDecl *Template);
1376 
1377  // Implement isa/cast/dyncast/etc.
1378  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1379  static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }
1380 };
1381 
1382 class ImplicitParamDecl : public VarDecl {
1383  void anchor() override;
1384 
1385 public:
1386  /// Defines the kind of the implicit parameter: is this an implicit parameter
1387  /// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured
1388  /// context or something else.
1389  enum ImplicitParamKind : unsigned {
1390  ObjCSelf, /// Parameter for Objective-C 'self' argument
1391  ObjCCmd, /// Parameter for Objective-C '_cmd' argument
1392  CXXThis, /// Parameter for C++ 'this' argument
1393  CXXVTT, /// Parameter for C++ virtual table pointers
1394  CapturedContext, /// Parameter for captured context
1395  Other, /// Other implicit parameter
1396  };
1397 
1398  /// Create implicit parameter.
1400  SourceLocation IdLoc, IdentifierInfo *Id,
1401  QualType T, ImplicitParamKind ParamKind);
1403  ImplicitParamKind ParamKind);
1404 
1405  static ImplicitParamDecl *CreateDeserialized(ASTContext &C, unsigned ID);
1406 
1409  ImplicitParamKind ParamKind)
1410  : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
1411  /*TInfo=*/nullptr, SC_None) {
1412  NonParmVarDeclBits.ImplicitParamKind = ParamKind;
1413  setImplicit();
1414  }
1415 
1417  : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
1418  SourceLocation(), /*Id=*/nullptr, Type,
1419  /*TInfo=*/nullptr, SC_None) {
1420  NonParmVarDeclBits.ImplicitParamKind = ParamKind;
1421  setImplicit();
1422  }
1423 
1424  /// Returns the implicit parameter kind.
1426  return static_cast<ImplicitParamKind>(NonParmVarDeclBits.ImplicitParamKind);
1427  }
1428  // Implement isa/cast/dyncast/etc.
1429  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1430  static bool classofKind(Kind K) { return K == ImplicitParam; }
1431 };
1432 
1433 /// ParmVarDecl - Represents a parameter to a function.
1434 class ParmVarDecl : public VarDecl {
1435 public:
1436  enum { MaxFunctionScopeDepth = 255 };
1437  enum { MaxFunctionScopeIndex = 255 };
1438 
1439 protected:
1441  SourceLocation IdLoc, IdentifierInfo *Id, QualType T,
1442  TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
1443  : VarDecl(DK, C, DC, StartLoc, IdLoc, Id, T, TInfo, S) {
1444  assert(ParmVarDeclBits.HasInheritedDefaultArg == false);
1445  assert(ParmVarDeclBits.DefaultArgKind == DAK_None);
1446  assert(ParmVarDeclBits.IsKNRPromoted == false);
1447  assert(ParmVarDeclBits.IsObjCMethodParam == false);
1448  setDefaultArg(DefArg);
1449  }
1450 
1451 public:
1452  static ParmVarDecl *Create(ASTContext &C, DeclContext *DC,
1453  SourceLocation StartLoc,
1454  SourceLocation IdLoc, IdentifierInfo *Id,
1455  QualType T, TypeSourceInfo *TInfo,
1456  StorageClass S, Expr *DefArg);
1457 
1458  static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
1459 
1460  SourceRange getSourceRange() const override LLVM_READONLY;
1461 
1462  void setObjCMethodScopeInfo(unsigned parameterIndex) {
1463  ParmVarDeclBits.IsObjCMethodParam = true;
1464  setParameterIndex(parameterIndex);
1465  }
1466 
1467  void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex) {
1468  assert(!ParmVarDeclBits.IsObjCMethodParam);
1469 
1470  ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth;
1471  assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth
1472  && "truncation!");
1473 
1474  setParameterIndex(parameterIndex);
1475  }
1476 
1477  bool isObjCMethodParameter() const {
1478  return ParmVarDeclBits.IsObjCMethodParam;
1479  }
1480 
1481  unsigned getFunctionScopeDepth() const {
1482  if (ParmVarDeclBits.IsObjCMethodParam) return 0;
1483  return ParmVarDeclBits.ScopeDepthOrObjCQuals;
1484  }
1485 
1486  /// Returns the index of this parameter in its prototype or method scope.
1487  unsigned getFunctionScopeIndex() const {
1488  return getParameterIndex();
1489  }
1490 
1492  if (!ParmVarDeclBits.IsObjCMethodParam) return OBJC_TQ_None;
1493  return ObjCDeclQualifier(ParmVarDeclBits.ScopeDepthOrObjCQuals);
1494  }
1496  assert(ParmVarDeclBits.IsObjCMethodParam);
1497  ParmVarDeclBits.ScopeDepthOrObjCQuals = QTVal;
1498  }
1499 
1500  /// True if the value passed to this parameter must undergo
1501  /// K&R-style default argument promotion:
1502  ///
1503  /// C99 6.5.2.2.
1504  /// If the expression that denotes the called function has a type
1505  /// that does not include a prototype, the integer promotions are
1506  /// performed on each argument, and arguments that have type float
1507  /// are promoted to double.
1508  bool isKNRPromoted() const {
1509  return ParmVarDeclBits.IsKNRPromoted;
1510  }
1511  void setKNRPromoted(bool promoted) {
1512  ParmVarDeclBits.IsKNRPromoted = promoted;
1513  }
1514 
1515  Expr *getDefaultArg();
1516  const Expr *getDefaultArg() const {
1517  return const_cast<ParmVarDecl *>(this)->getDefaultArg();
1518  }
1519 
1520  void setDefaultArg(Expr *defarg);
1521 
1522  /// \brief Retrieve the source range that covers the entire default
1523  /// argument.
1525  void setUninstantiatedDefaultArg(Expr *arg);
1528  return const_cast<ParmVarDecl *>(this)->getUninstantiatedDefaultArg();
1529  }
1530 
1531  /// hasDefaultArg - Determines whether this parameter has a default argument,
1532  /// either parsed or not.
1533  bool hasDefaultArg() const;
1534 
1535  /// hasUnparsedDefaultArg - Determines whether this parameter has a
1536  /// default argument that has not yet been parsed. This will occur
1537  /// during the processing of a C++ class whose member functions have
1538  /// default arguments, e.g.,
1539  /// @code
1540  /// class X {
1541  /// public:
1542  /// void f(int x = 17); // x has an unparsed default argument now
1543  /// }; // x has a regular default argument now
1544  /// @endcode
1545  bool hasUnparsedDefaultArg() const {
1546  return ParmVarDeclBits.DefaultArgKind == DAK_Unparsed;
1547  }
1548 
1550  return ParmVarDeclBits.DefaultArgKind == DAK_Uninstantiated;
1551  }
1552 
1553  /// setUnparsedDefaultArg - Specify that this parameter has an
1554  /// unparsed default argument. The argument will be replaced with a
1555  /// real default argument via setDefaultArg when the class
1556  /// definition enclosing the function declaration that owns this
1557  /// default argument is completed.
1559  ParmVarDeclBits.DefaultArgKind = DAK_Unparsed;
1560  }
1561 
1562  bool hasInheritedDefaultArg() const {
1563  return ParmVarDeclBits.HasInheritedDefaultArg;
1564  }
1565 
1566  void setHasInheritedDefaultArg(bool I = true) {
1567  ParmVarDeclBits.HasInheritedDefaultArg = I;
1568  }
1569 
1570  QualType getOriginalType() const;
1571 
1572  /// \brief Determine whether this parameter is actually a function
1573  /// parameter pack.
1574  bool isParameterPack() const;
1575 
1576  /// setOwningFunction - Sets the function declaration that owns this
1577  /// ParmVarDecl. Since ParmVarDecls are often created before the
1578  /// FunctionDecls that own them, this routine is required to update
1579  /// the DeclContext appropriately.
1581 
1582  // Implement isa/cast/dyncast/etc.
1583  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1584  static bool classofKind(Kind K) { return K == ParmVar; }
1585 
1586 private:
1587  enum { ParameterIndexSentinel = (1 << NumParameterIndexBits) - 1 };
1588 
1589  void setParameterIndex(unsigned parameterIndex) {
1590  if (parameterIndex >= ParameterIndexSentinel) {
1591  setParameterIndexLarge(parameterIndex);
1592  return;
1593  }
1594 
1595  ParmVarDeclBits.ParameterIndex = parameterIndex;
1596  assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!");
1597  }
1598  unsigned getParameterIndex() const {
1599  unsigned d = ParmVarDeclBits.ParameterIndex;
1600  return d == ParameterIndexSentinel ? getParameterIndexLarge() : d;
1601  }
1602 
1603  void setParameterIndexLarge(unsigned parameterIndex);
1604  unsigned getParameterIndexLarge() const;
1605 };
1606 
1607 /// FunctionDecl - An instance of this class is created to represent a
1608 /// function declaration or definition.
1609 ///
1610 /// Since a given function can be declared several times in a program,
1611 /// there may be several FunctionDecls that correspond to that
1612 /// function. Only one of those FunctionDecls will be found when
1613 /// traversing the list of declarations in the context of the
1614 /// FunctionDecl (e.g., the translation unit); this FunctionDecl
1615 /// contains all of the information known about the function. Other,
1616 /// previous declarations of the function are available via the
1617 /// getPreviousDecl() chain.
1618 class FunctionDecl : public DeclaratorDecl, public DeclContext,
1619  public Redeclarable<FunctionDecl> {
1620 public:
1621  /// \brief The kind of templated function a FunctionDecl can be.
1627  TK_DependentFunctionTemplateSpecialization
1628  };
1629 
1630 private:
1631  /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
1632  /// parameters of this function. This is null if a prototype or if there are
1633  /// no formals.
1634  ParmVarDecl **ParamInfo;
1635 
1636  LazyDeclStmtPtr Body;
1637 
1638  // FIXME: This can be packed into the bitfields in DeclContext.
1639  // NOTE: VC++ packs bitfields poorly if the types differ.
1640  unsigned SClass : 3;
1641  unsigned IsInline : 1;
1642  unsigned IsInlineSpecified : 1;
1643 protected:
1644  // This is shared by CXXConstructorDecl, CXXConversionDecl, and
1645  // CXXDeductionGuideDecl.
1646  unsigned IsExplicitSpecified : 1;
1647 private:
1648  unsigned IsVirtualAsWritten : 1;
1649  unsigned IsPure : 1;
1650  unsigned HasInheritedPrototype : 1;
1651  unsigned HasWrittenPrototype : 1;
1652  unsigned IsDeleted : 1;
1653  unsigned IsTrivial : 1; // sunk from CXXMethodDecl
1654  unsigned IsDefaulted : 1; // sunk from CXXMethoDecl
1655  unsigned IsExplicitlyDefaulted : 1; //sunk from CXXMethodDecl
1656  unsigned HasImplicitReturnZero : 1;
1657  unsigned IsLateTemplateParsed : 1;
1658  unsigned IsConstexpr : 1;
1659  unsigned InstantiationIsPending:1;
1660 
1661  /// \brief Indicates if the function uses __try.
1662  unsigned UsesSEHTry : 1;
1663 
1664  /// \brief Indicates if the function was a definition but its body was
1665  /// skipped.
1666  unsigned HasSkippedBody : 1;
1667 
1668  /// Indicates if the function declaration will have a body, once we're done
1669  /// parsing it.
1670  unsigned WillHaveBody : 1;
1671 
1672  /// \brief End part of this FunctionDecl's source range.
1673  ///
1674  /// We could compute the full range in getSourceRange(). However, when we're
1675  /// dealing with a function definition deserialized from a PCH/AST file,
1676  /// we can only compute the full range once the function body has been
1677  /// de-serialized, so it's far better to have the (sometimes-redundant)
1678  /// EndRangeLoc.
1679  SourceLocation EndRangeLoc;
1680 
1681  /// \brief The template or declaration that this declaration
1682  /// describes or was instantiated from, respectively.
1683  ///
1684  /// For non-templates, this value will be NULL. For function
1685  /// declarations that describe a function template, this will be a
1686  /// pointer to a FunctionTemplateDecl. For member functions
1687  /// of class template specializations, this will be a MemberSpecializationInfo
1688  /// pointer containing information about the specialization.
1689  /// For function template specializations, this will be a
1690  /// FunctionTemplateSpecializationInfo, which contains information about
1691  /// the template being specialized and the template arguments involved in
1692  /// that specialization.
1693  llvm::PointerUnion4<FunctionTemplateDecl *,
1697  TemplateOrSpecialization;
1698 
1699  /// DNLoc - Provides source/type location info for the
1700  /// declaration name embedded in the DeclaratorDecl base class.
1701  DeclarationNameLoc DNLoc;
1702 
1703  /// \brief Specify that this function declaration is actually a function
1704  /// template specialization.
1705  ///
1706  /// \param C the ASTContext.
1707  ///
1708  /// \param Template the function template that this function template
1709  /// specialization specializes.
1710  ///
1711  /// \param TemplateArgs the template arguments that produced this
1712  /// function template specialization from the template.
1713  ///
1714  /// \param InsertPos If non-NULL, the position in the function template
1715  /// specialization set where the function template specialization data will
1716  /// be inserted.
1717  ///
1718  /// \param TSK the kind of template specialization this is.
1719  ///
1720  /// \param TemplateArgsAsWritten location info of template arguments.
1721  ///
1722  /// \param PointOfInstantiation point at which the function template
1723  /// specialization was first instantiated.
1724  void setFunctionTemplateSpecialization(ASTContext &C,
1725  FunctionTemplateDecl *Template,
1726  const TemplateArgumentList *TemplateArgs,
1727  void *InsertPos,
1729  const TemplateArgumentListInfo *TemplateArgsAsWritten,
1730  SourceLocation PointOfInstantiation);
1731 
1732  /// \brief Specify that this record is an instantiation of the
1733  /// member function FD.
1734  void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD,
1736 
1737  void setParams(ASTContext &C, ArrayRef<ParmVarDecl *> NewParamInfo);
1738 
1739 protected:
1741  const DeclarationNameInfo &NameInfo, QualType T,
1743  bool isConstexprSpecified)
1744  : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
1745  StartLoc),
1746  DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(),
1747  SClass(S), IsInline(isInlineSpecified),
1748  IsInlineSpecified(isInlineSpecified), IsExplicitSpecified(false),
1749  IsVirtualAsWritten(false), IsPure(false),
1750  HasInheritedPrototype(false), HasWrittenPrototype(true),
1751  IsDeleted(false), IsTrivial(false), IsDefaulted(false),
1752  IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
1753  IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
1754  InstantiationIsPending(false),
1755  UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false),
1756  EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(),
1757  DNLoc(NameInfo.getInfo()) {}
1758 
1761  return getNextRedeclaration();
1762  }
1764  return getPreviousDecl();
1765  }
1767  return getMostRecentDecl();
1768  }
1769 
1770 public:
1772  typedef redeclarable_base::redecl_iterator redecl_iterator;
1779 
1781  SourceLocation StartLoc, SourceLocation NLoc,
1783  TypeSourceInfo *TInfo,
1784  StorageClass SC,
1785  bool isInlineSpecified = false,
1786  bool hasWrittenPrototype = true,
1787  bool isConstexprSpecified = false) {
1788  DeclarationNameInfo NameInfo(N, NLoc);
1789  return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo,
1790  SC,
1791  isInlineSpecified, hasWrittenPrototype,
1792  isConstexprSpecified);
1793  }
1794 
1795  static FunctionDecl *Create(ASTContext &C, DeclContext *DC,
1796  SourceLocation StartLoc,
1797  const DeclarationNameInfo &NameInfo,
1798  QualType T, TypeSourceInfo *TInfo,
1799  StorageClass SC,
1800  bool isInlineSpecified,
1801  bool hasWrittenPrototype,
1802  bool isConstexprSpecified = false);
1803 
1804  static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID);
1805 
1807  return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
1808  }
1809 
1810  void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
1811  bool Qualified) const override;
1812 
1813  void setRangeEnd(SourceLocation E) { EndRangeLoc = E; }
1814 
1815  SourceRange getSourceRange() const override LLVM_READONLY;
1816 
1817  /// \brief Returns true if the function has a body (definition). The
1818  /// function body might be in any of the (re-)declarations of this
1819  /// function. The variant that accepts a FunctionDecl pointer will
1820  /// set that function declaration to the actual declaration
1821  /// containing the body (if there is one).
1822  bool hasBody(const FunctionDecl *&Definition) const;
1823 
1824  bool hasBody() const override {
1825  const FunctionDecl* Definition;
1826  return hasBody(Definition);
1827  }
1828 
1829  /// hasTrivialBody - Returns whether the function has a trivial body that does
1830  /// not require any specific codegen.
1831  bool hasTrivialBody() const;
1832 
1833  /// isDefined - Returns true if the function is defined at all, including
1834  /// a deleted definition. Except for the behavior when the function is
1835  /// deleted, behaves like hasBody.
1836  bool isDefined(const FunctionDecl *&Definition) const;
1837 
1838  virtual bool isDefined() const {
1839  const FunctionDecl* Definition;
1840  return isDefined(Definition);
1841  }
1842 
1843  /// \brief Get the definition for this declaration.
1845  const FunctionDecl *Definition;
1846  if (isDefined(Definition))
1847  return const_cast<FunctionDecl *>(Definition);
1848  return nullptr;
1849  }
1850  const FunctionDecl *getDefinition() const {
1851  return const_cast<FunctionDecl *>(this)->getDefinition();
1852  }
1853 
1854  /// getBody - Retrieve the body (definition) of the function. The
1855  /// function body might be in any of the (re-)declarations of this
1856  /// function. The variant that accepts a FunctionDecl pointer will
1857  /// set that function declaration to the actual declaration
1858  /// containing the body (if there is one).
1859  /// NOTE: For checking if there is a body, use hasBody() instead, to avoid
1860  /// unnecessary AST de-serialization of the body.
1861  Stmt *getBody(const FunctionDecl *&Definition) const;
1862 
1863  Stmt *getBody() const override {
1864  const FunctionDecl* Definition;
1865  return getBody(Definition);
1866  }
1867 
1868  /// Returns whether this specific declaration of the function is also a
1869  /// definition that does not contain uninstantiated body.
1870  ///
1871  /// This does not determine whether the function has been defined (e.g., in a
1872  /// previous definition); for that information, use isDefined.
1873  ///
1875  return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed ||
1876  WillHaveBody || hasDefiningAttr();
1877  }
1878 
1879  /// doesThisDeclarationHaveABody - Returns whether this specific
1880  /// declaration of the function has a body - that is, if it is a non-
1881  /// deleted definition.
1883  return Body || IsLateTemplateParsed;
1884  }
1885 
1886  void setBody(Stmt *B);
1887  void setLazyBody(uint64_t Offset) { Body = Offset; }
1888 
1889  /// Whether this function is variadic.
1890  bool isVariadic() const;
1891 
1892  /// Whether this function is marked as virtual explicitly.
1893  bool isVirtualAsWritten() const { return IsVirtualAsWritten; }
1894  void setVirtualAsWritten(bool V) { IsVirtualAsWritten = V; }
1895 
1896  /// Whether this virtual function is pure, i.e. makes the containing class
1897  /// abstract.
1898  bool isPure() const { return IsPure; }
1899  void setPure(bool P = true);
1900 
1901  /// Whether this templated function will be late parsed.
1902  bool isLateTemplateParsed() const { return IsLateTemplateParsed; }
1903  void setLateTemplateParsed(bool ILT = true) { IsLateTemplateParsed = ILT; }
1904 
1905  /// Whether this function is "trivial" in some specialized C++ senses.
1906  /// Can only be true for default constructors, copy constructors,
1907  /// copy assignment operators, and destructors. Not meaningful until
1908  /// the class has been fully built by Sema.
1909  bool isTrivial() const { return IsTrivial; }
1910  void setTrivial(bool IT) { IsTrivial = IT; }
1911 
1912  /// Whether this function is defaulted per C++0x. Only valid for
1913  /// special member functions.
1914  bool isDefaulted() const { return IsDefaulted; }
1915  void setDefaulted(bool D = true) { IsDefaulted = D; }
1916 
1917  /// Whether this function is explicitly defaulted per C++0x. Only valid
1918  /// for special member functions.
1919  bool isExplicitlyDefaulted() const { return IsExplicitlyDefaulted; }
1920  void setExplicitlyDefaulted(bool ED = true) { IsExplicitlyDefaulted = ED; }
1921 
1922  /// Whether falling off this function implicitly returns null/zero.
1923  /// If a more specific implicit return value is required, front-ends
1924  /// should synthesize the appropriate return statements.
1925  bool hasImplicitReturnZero() const { return HasImplicitReturnZero; }
1926  void setHasImplicitReturnZero(bool IRZ) { HasImplicitReturnZero = IRZ; }
1927 
1928  /// \brief Whether this function has a prototype, either because one
1929  /// was explicitly written or because it was "inherited" by merging
1930  /// a declaration without a prototype with a declaration that has a
1931  /// prototype.
1932  bool hasPrototype() const {
1933  return HasWrittenPrototype || HasInheritedPrototype;
1934  }
1935 
1936  bool hasWrittenPrototype() const { return HasWrittenPrototype; }
1937 
1938  /// \brief Whether this function inherited its prototype from a
1939  /// previous declaration.
1940  bool hasInheritedPrototype() const { return HasInheritedPrototype; }
1941  void setHasInheritedPrototype(bool P = true) { HasInheritedPrototype = P; }
1942 
1943  /// Whether this is a (C++11) constexpr function or constexpr constructor.
1944  bool isConstexpr() const { return IsConstexpr; }
1945  void setConstexpr(bool IC) { IsConstexpr = IC; }
1946 
1947  /// \brief Whether the instantiation of this function is pending.
1948  /// This bit is set when the decision to instantiate this function is made
1949  /// and unset if and when the function body is created. That leaves out
1950  /// cases where instantiation did not happen because the template definition
1951  /// was not seen in this TU. This bit remains set in those cases, under the
1952  /// assumption that the instantiation will happen in some other TU.
1953  bool instantiationIsPending() const { return InstantiationIsPending; }
1954  void setInstantiationIsPending(bool IC) { InstantiationIsPending = IC; }
1955 
1956  /// \brief Indicates the function uses __try.
1957  bool usesSEHTry() const { return UsesSEHTry; }
1958  void setUsesSEHTry(bool UST) { UsesSEHTry = UST; }
1959 
1960  /// \brief Whether this function has been deleted.
1961  ///
1962  /// A function that is "deleted" (via the C++0x "= delete" syntax)
1963  /// acts like a normal function, except that it cannot actually be
1964  /// called or have its address taken. Deleted functions are
1965  /// typically used in C++ overload resolution to attract arguments
1966  /// whose type or lvalue/rvalue-ness would permit the use of a
1967  /// different overload that would behave incorrectly. For example,
1968  /// one might use deleted functions to ban implicit conversion from
1969  /// a floating-point number to an Integer type:
1970  ///
1971  /// @code
1972  /// struct Integer {
1973  /// Integer(long); // construct from a long
1974  /// Integer(double) = delete; // no construction from float or double
1975  /// Integer(long double) = delete; // no construction from long double
1976  /// };
1977  /// @endcode
1978  // If a function is deleted, its first declaration must be.
1979  bool isDeleted() const { return getCanonicalDecl()->IsDeleted; }
1980  bool isDeletedAsWritten() const { return IsDeleted && !IsDefaulted; }
1981  void setDeletedAsWritten(bool D = true) { IsDeleted = D; }
1982 
1983  /// \brief Determines whether this function is "main", which is the
1984  /// entry point into an executable program.
1985  bool isMain() const;
1986 
1987  /// \brief Determines whether this function is a MSVCRT user defined entry
1988  /// point.
1989  bool isMSVCRTEntryPoint() const;
1990 
1991  /// \brief Determines whether this operator new or delete is one
1992  /// of the reserved global placement operators:
1993  /// void *operator new(size_t, void *);
1994  /// void *operator new[](size_t, void *);
1995  /// void operator delete(void *, void *);
1996  /// void operator delete[](void *, void *);
1997  /// These functions have special behavior under [new.delete.placement]:
1998  /// These functions are reserved, a C++ program may not define
1999  /// functions that displace the versions in the Standard C++ library.
2000  /// The provisions of [basic.stc.dynamic] do not apply to these
2001  /// reserved placement forms of operator new and operator delete.
2002  ///
2003  /// This function must be an allocation or deallocation function.
2004  bool isReservedGlobalPlacementOperator() const;
2005 
2006  /// \brief Determines whether this function is one of the replaceable
2007  /// global allocation functions:
2008  /// void *operator new(size_t);
2009  /// void *operator new(size_t, const std::nothrow_t &) noexcept;
2010  /// void *operator new[](size_t);
2011  /// void *operator new[](size_t, const std::nothrow_t &) noexcept;
2012  /// void operator delete(void *) noexcept;
2013  /// void operator delete(void *, std::size_t) noexcept; [C++1y]
2014  /// void operator delete(void *, const std::nothrow_t &) noexcept;
2015  /// void operator delete[](void *) noexcept;
2016  /// void operator delete[](void *, std::size_t) noexcept; [C++1y]
2017  /// void operator delete[](void *, const std::nothrow_t &) noexcept;
2018  /// These functions have special behavior under C++1y [expr.new]:
2019  /// An implementation is allowed to omit a call to a replaceable global
2020  /// allocation function. [...]
2021  ///
2022  /// If this function is an aligned allocation/deallocation function, return
2023  /// true through IsAligned.
2024  bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) const;
2025 
2026  /// Compute the language linkage.
2028 
2029  /// \brief Determines whether this function is a function with
2030  /// external, C linkage.
2031  bool isExternC() const;
2032 
2033  /// \brief Determines whether this function's context is, or is nested within,
2034  /// a C++ extern "C" linkage spec.
2035  bool isInExternCContext() const;
2036 
2037  /// \brief Determines whether this function's context is, or is nested within,
2038  /// a C++ extern "C++" linkage spec.
2039  bool isInExternCXXContext() const;
2040 
2041  /// \brief Determines whether this is a global function.
2042  bool isGlobal() const;
2043 
2044  /// \brief Determines whether this function is known to be 'noreturn', through
2045  /// an attribute on its declaration or its type.
2046  bool isNoReturn() const;
2047 
2048  /// \brief True if the function was a definition but its body was skipped.
2049  bool hasSkippedBody() const { return HasSkippedBody; }
2050  void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; }
2051 
2052  /// True if this function will eventually have a body, once it's fully parsed.
2053  bool willHaveBody() const { return WillHaveBody; }
2054  void setWillHaveBody(bool V = true) { WillHaveBody = V; }
2055 
2056  void setPreviousDeclaration(FunctionDecl * PrevDecl);
2057 
2058  FunctionDecl *getCanonicalDecl() override;
2060  return const_cast<FunctionDecl*>(this)->getCanonicalDecl();
2061  }
2062 
2063  unsigned getBuiltinID() const;
2064 
2065  // ArrayRef interface to parameters.
2067  return {ParamInfo, getNumParams()};
2068  }
2070  return {ParamInfo, getNumParams()};
2071  }
2072 
2073  // Iterator access to formal parameters.
2076  bool param_empty() const { return parameters().empty(); }
2077  param_iterator param_begin() { return parameters().begin(); }
2078  param_iterator param_end() { return parameters().end(); }
2079  param_const_iterator param_begin() const { return parameters().begin(); }
2080  param_const_iterator param_end() const { return parameters().end(); }
2081  size_t param_size() const { return parameters().size(); }
2082 
2083  /// getNumParams - Return the number of parameters this function must have
2084  /// based on its FunctionType. This is the length of the ParamInfo array
2085  /// after it has been created.
2086  unsigned getNumParams() const;
2087 
2088  const ParmVarDecl *getParamDecl(unsigned i) const {
2089  assert(i < getNumParams() && "Illegal param #");
2090  return ParamInfo[i];
2091  }
2092  ParmVarDecl *getParamDecl(unsigned i) {
2093  assert(i < getNumParams() && "Illegal param #");
2094  return ParamInfo[i];
2095  }
2096  void setParams(ArrayRef<ParmVarDecl *> NewParamInfo) {
2097  setParams(getASTContext(), NewParamInfo);
2098  }
2099 
2100  /// getMinRequiredArguments - Returns the minimum number of arguments
2101  /// needed to call this function. This may be fewer than the number of
2102  /// function parameters, if some of the parameters have default
2103  /// arguments (in C++).
2104  unsigned getMinRequiredArguments() const;
2105 
2107  assert(getType()->getAs<FunctionType>() && "Expected a FunctionType!");
2108  return getType()->getAs<FunctionType>()->getReturnType();
2109  }
2110 
2111  /// \brief Attempt to compute an informative source range covering the
2112  /// function return type. This may omit qualifiers and other information with
2113  /// limited representation in the AST.
2114  SourceRange getReturnTypeSourceRange() const;
2115 
2116  /// \brief Attempt to compute an informative source range covering the
2117  /// function exception specification, if any.
2118  SourceRange getExceptionSpecSourceRange() const;
2119 
2120  /// \brief Determine the type of an expression that calls this function.
2122  assert(getType()->getAs<FunctionType>() && "Expected a FunctionType!");
2123  return getType()->getAs<FunctionType>()->getCallResultType(getASTContext());
2124  }
2125 
2126  /// \brief Returns the WarnUnusedResultAttr that is either declared on this
2127  /// function, or its return type declaration.
2128  const Attr *getUnusedResultAttr() const;
2129 
2130  /// \brief Returns true if this function or its return type has the
2131  /// warn_unused_result attribute.
2132  bool hasUnusedResultAttr() const { return getUnusedResultAttr() != nullptr; }
2133 
2134  /// \brief Returns the storage class as written in the source. For the
2135  /// computed linkage of symbol, see getLinkage.
2136  StorageClass getStorageClass() const { return StorageClass(SClass); }
2137 
2138  /// \brief Determine whether the "inline" keyword was specified for this
2139  /// function.
2140  bool isInlineSpecified() const { return IsInlineSpecified; }
2141 
2142  /// Set whether the "inline" keyword was specified for this function.
2143  void setInlineSpecified(bool I) {
2144  IsInlineSpecified = I;
2145  IsInline = I;
2146  }
2147 
2148  /// Flag that this function is implicitly inline.
2150  IsInline = true;
2151  }
2152 
2153  /// \brief Determine whether this function should be inlined, because it is
2154  /// either marked "inline" or "constexpr" or is a member function of a class
2155  /// that was defined in the class body.
2156  bool isInlined() const { return IsInline; }
2157 
2158  bool isInlineDefinitionExternallyVisible() const;
2159 
2160  bool isMSExternInline() const;
2161 
2162  bool doesDeclarationForceExternallyVisibleDefinition() const;
2163 
2164  /// isOverloadedOperator - Whether this function declaration
2165  /// represents an C++ overloaded operator, e.g., "operator+".
2166  bool isOverloadedOperator() const {
2167  return getOverloadedOperator() != OO_None;
2168  }
2169 
2170  OverloadedOperatorKind getOverloadedOperator() const;
2171 
2172  const IdentifierInfo *getLiteralIdentifier() const;
2173 
2174  /// \brief If this function is an instantiation of a member function
2175  /// of a class template specialization, retrieves the function from
2176  /// which it was instantiated.
2177  ///
2178  /// This routine will return non-NULL for (non-templated) member
2179  /// functions of class templates and for instantiations of function
2180  /// templates. For example, given:
2181  ///
2182  /// \code
2183  /// template<typename T>
2184  /// struct X {
2185  /// void f(T);
2186  /// };
2187  /// \endcode
2188  ///
2189  /// The declaration for X<int>::f is a (non-templated) FunctionDecl
2190  /// whose parent is the class template specialization X<int>. For
2191  /// this declaration, getInstantiatedFromFunction() will return
2192  /// the FunctionDecl X<T>::A. When a complete definition of
2193  /// X<int>::A is required, it will be instantiated from the
2194  /// declaration returned by getInstantiatedFromMemberFunction().
2195  FunctionDecl *getInstantiatedFromMemberFunction() const;
2196 
2197  /// \brief What kind of templated function this is.
2198  TemplatedKind getTemplatedKind() const;
2199 
2200  /// \brief If this function is an instantiation of a member function of a
2201  /// class template specialization, retrieves the member specialization
2202  /// information.
2204 
2205  /// \brief Specify that this record is an instantiation of the
2206  /// member function FD.
2209  setInstantiationOfMemberFunction(getASTContext(), FD, TSK);
2210  }
2211 
2212  /// \brief Retrieves the function template that is described by this
2213  /// function declaration.
2214  ///
2215  /// Every function template is represented as a FunctionTemplateDecl
2216  /// and a FunctionDecl (or something derived from FunctionDecl). The
2217  /// former contains template properties (such as the template
2218  /// parameter lists) while the latter contains the actual
2219  /// description of the template's
2220  /// contents. FunctionTemplateDecl::getTemplatedDecl() retrieves the
2221  /// FunctionDecl that describes the function template,
2222  /// getDescribedFunctionTemplate() retrieves the
2223  /// FunctionTemplateDecl from a FunctionDecl.
2224  FunctionTemplateDecl *getDescribedFunctionTemplate() const;
2225 
2226  void setDescribedFunctionTemplate(FunctionTemplateDecl *Template);
2227 
2228  /// \brief Determine whether this function is a function template
2229  /// specialization.
2231  return getPrimaryTemplate() != nullptr;
2232  }
2233 
2234  /// \brief Retrieve the class scope template pattern that this function
2235  /// template specialization is instantiated from.
2236  FunctionDecl *getClassScopeSpecializationPattern() const;
2237 
2238  /// \brief If this function is actually a function template specialization,
2239  /// retrieve information about this function template specialization.
2240  /// Otherwise, returns NULL.
2241  FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const;
2242 
2243  /// \brief Determines whether this function is a function template
2244  /// specialization or a member of a class template specialization that can
2245  /// be implicitly instantiated.
2246  bool isImplicitlyInstantiable() const;
2247 
2248  /// \brief Determines if the given function was instantiated from a
2249  /// function template.
2250  bool isTemplateInstantiation() const;
2251 
2252  /// \brief Retrieve the function declaration from which this function could
2253  /// be instantiated, if it is an instantiation (rather than a non-template
2254  /// or a specialization, for example).
2256 
2257  /// \brief Retrieve the primary template that this function template
2258  /// specialization either specializes or was instantiated from.
2259  ///
2260  /// If this function declaration is not a function template specialization,
2261  /// returns NULL.
2262  FunctionTemplateDecl *getPrimaryTemplate() const;
2263 
2264  /// \brief Retrieve the template arguments used to produce this function
2265  /// template specialization from the primary template.
2266  ///
2267  /// If this function declaration is not a function template specialization,
2268  /// returns NULL.
2269  const TemplateArgumentList *getTemplateSpecializationArgs() const;
2270 
2271  /// \brief Retrieve the template argument list as written in the sources,
2272  /// if any.
2273  ///
2274  /// If this function declaration is not a function template specialization
2275  /// or if it had no explicit template argument list, returns NULL.
2276  /// Note that it an explicit template argument list may be written empty,
2277  /// e.g., template<> void foo<>(char* s);
2279  getTemplateSpecializationArgsAsWritten() const;
2280 
2281  /// \brief Specify that this function declaration is actually a function
2282  /// template specialization.
2283  ///
2284  /// \param Template the function template that this function template
2285  /// specialization specializes.
2286  ///
2287  /// \param TemplateArgs the template arguments that produced this
2288  /// function template specialization from the template.
2289  ///
2290  /// \param InsertPos If non-NULL, the position in the function template
2291  /// specialization set where the function template specialization data will
2292  /// be inserted.
2293  ///
2294  /// \param TSK the kind of template specialization this is.
2295  ///
2296  /// \param TemplateArgsAsWritten location info of template arguments.
2297  ///
2298  /// \param PointOfInstantiation point at which the function template
2299  /// specialization was first instantiated.
2301  const TemplateArgumentList *TemplateArgs,
2302  void *InsertPos,
2304  const TemplateArgumentListInfo *TemplateArgsAsWritten = nullptr,
2305  SourceLocation PointOfInstantiation = SourceLocation()) {
2306  setFunctionTemplateSpecialization(getASTContext(), Template, TemplateArgs,
2307  InsertPos, TSK, TemplateArgsAsWritten,
2308  PointOfInstantiation);
2309  }
2310 
2311  /// \brief Specifies that this function declaration is actually a
2312  /// dependent function template specialization.
2313  void setDependentTemplateSpecialization(ASTContext &Context,
2314  const UnresolvedSetImpl &Templates,
2315  const TemplateArgumentListInfo &TemplateArgs);
2316 
2318  getDependentSpecializationInfo() const;
2319 
2320  /// \brief Determine what kind of template instantiation this function
2321  /// represents.
2323 
2324  /// \brief Determine what kind of template instantiation this function
2325  /// represents.
2327  SourceLocation PointOfInstantiation = SourceLocation());
2328 
2329  /// \brief Retrieve the (first) point of instantiation of a function template
2330  /// specialization or a member of a class template specialization.
2331  ///
2332  /// \returns the first point of instantiation, if this function was
2333  /// instantiated from a template; otherwise, returns an invalid source
2334  /// location.
2336 
2337  /// \brief Determine whether this is or was instantiated from an out-of-line
2338  /// definition of a member function.
2339  bool isOutOfLine() const override;
2340 
2341  /// \brief Identify a memory copying or setting function.
2342  /// If the given function is a memory copy or setting function, returns
2343  /// the corresponding Builtin ID. If the function is not a memory function,
2344  /// returns 0.
2345  unsigned getMemoryFunctionKind() const;
2346 
2347  // Implement isa/cast/dyncast/etc.
2348  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2349  static bool classofKind(Kind K) {
2350  return K >= firstFunction && K <= lastFunction;
2351  }
2353  return static_cast<DeclContext *>(const_cast<FunctionDecl*>(D));
2354  }
2356  return static_cast<FunctionDecl *>(const_cast<DeclContext*>(DC));
2357  }
2358 
2359  friend class ASTDeclReader;
2360  friend class ASTDeclWriter;
2361 };
2362 
2363 
2364 /// FieldDecl - An instance of this class is created by Sema::ActOnField to
2365 /// represent a member of a struct/union/class.
2366 class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
2367  // FIXME: This can be packed into the bitfields in Decl.
2368  unsigned Mutable : 1;
2369  mutable unsigned CachedFieldIndex : 31;
2370 
2371  /// The kinds of value we can store in InitializerOrBitWidth.
2372  ///
2373  /// Note that this is compatible with InClassInitStyle except for
2374  /// ISK_CapturedVLAType.
2375  enum InitStorageKind {
2376  /// If the pointer is null, there's nothing special. Otherwise,
2377  /// this is a bitfield and the pointer is the Expr* storing the
2378  /// bit-width.
2379  ISK_BitWidthOrNothing = (unsigned) ICIS_NoInit,
2380 
2381  /// The pointer is an (optional due to delayed parsing) Expr*
2382  /// holding the copy-initializer.
2383  ISK_InClassCopyInit = (unsigned) ICIS_CopyInit,
2384 
2385  /// The pointer is an (optional due to delayed parsing) Expr*
2386  /// holding the list-initializer.
2387  ISK_InClassListInit = (unsigned) ICIS_ListInit,
2388 
2389  /// The pointer is a VariableArrayType* that's been captured;
2390  /// the enclosing context is a lambda or captured statement.
2391  ISK_CapturedVLAType,
2392  };
2393 
2394  /// \brief Storage for either the bit-width, the in-class
2395  /// initializer, or the captured variable length array bound.
2396  ///
2397  /// We can safely combine these because in-class initializers are
2398  /// not permitted for bit-fields, and both are exclusive with VLA
2399  /// captures.
2400  ///
2401  /// If the storage kind is ISK_InClassCopyInit or
2402  /// ISK_InClassListInit, but the initializer is null, then this
2403  /// field has an in-class initializer which has not yet been parsed
2404  /// and attached.
2405  llvm::PointerIntPair<void *, 2, InitStorageKind> InitStorage;
2406 protected:
2408  SourceLocation IdLoc, IdentifierInfo *Id,
2409  QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
2410  InClassInitStyle InitStyle)
2411  : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc),
2412  Mutable(Mutable), CachedFieldIndex(0),
2413  InitStorage(BW, (InitStorageKind) InitStyle) {
2414  assert((!BW || InitStyle == ICIS_NoInit) && "got initializer for bitfield");
2415  }
2416 
2417 public:
2418  static FieldDecl *Create(const ASTContext &C, DeclContext *DC,
2419  SourceLocation StartLoc, SourceLocation IdLoc,
2420  IdentifierInfo *Id, QualType T,
2421  TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
2422  InClassInitStyle InitStyle);
2423 
2424  static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2425 
2426  /// getFieldIndex - Returns the index of this field within its record,
2427  /// as appropriate for passing to ASTRecordLayout::getFieldOffset.
2428  unsigned getFieldIndex() const;
2429 
2430  /// isMutable - Determines whether this field is mutable (C++ only).
2431  bool isMutable() const { return Mutable; }
2432 
2433  /// \brief Determines whether this field is a bitfield.
2434  bool isBitField() const {
2435  return InitStorage.getInt() == ISK_BitWidthOrNothing &&
2436  InitStorage.getPointer() != nullptr;
2437  }
2438 
2439  /// @brief Determines whether this is an unnamed bitfield.
2440  bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); }
2441 
2442  /// isAnonymousStructOrUnion - Determines whether this field is a
2443  /// representative for an anonymous struct or union. Such fields are
2444  /// unnamed and are implicitly generated by the implementation to
2445  /// store the data for the anonymous union or struct.
2446  bool isAnonymousStructOrUnion() const;
2447 
2448  Expr *getBitWidth() const {
2449  return isBitField()
2450  ? static_cast<Expr *>(InitStorage.getPointer())
2451  : nullptr;
2452  }
2453  unsigned getBitWidthValue(const ASTContext &Ctx) const;
2454 
2455  /// setBitWidth - Set the bit-field width for this member.
2456  // Note: used by some clients (i.e., do not remove it).
2457  void setBitWidth(Expr *Width) {
2458  assert(InitStorage.getInt() == ISK_BitWidthOrNothing &&
2459  InitStorage.getPointer() == nullptr &&
2460  "bit width, initializer or captured type already set");
2461  InitStorage.setPointerAndInt(Width, ISK_BitWidthOrNothing);
2462  }
2463 
2464  /// removeBitWidth - Remove the bit-field width from this member.
2465  // Note: used by some clients (i.e., do not remove it).
2467  assert(isBitField() && "no bitfield width to remove");
2468  InitStorage.setPointerAndInt(nullptr, ISK_BitWidthOrNothing);
2469  }
2470 
2471  /// getInClassInitStyle - Get the kind of (C++11) in-class initializer which
2472  /// this field has.
2474  InitStorageKind storageKind = InitStorage.getInt();
2475  return (storageKind == ISK_CapturedVLAType
2476  ? ICIS_NoInit : (InClassInitStyle) storageKind);
2477  }
2478 
2479  /// hasInClassInitializer - Determine whether this member has a C++11 in-class
2480  /// initializer.
2481  bool hasInClassInitializer() const {
2482  return getInClassInitStyle() != ICIS_NoInit;
2483  }
2484 
2485  /// getInClassInitializer - Get the C++11 in-class initializer for this
2486  /// member, or null if one has not been set. If a valid declaration has an
2487  /// in-class initializer, but this returns null, then we have not parsed and
2488  /// attached it yet.
2490  return hasInClassInitializer()
2491  ? static_cast<Expr *>(InitStorage.getPointer())
2492  : nullptr;
2493  }
2494 
2495  /// setInClassInitializer - Set the C++11 in-class initializer for this
2496  /// member.
2498  assert(hasInClassInitializer() &&
2499  InitStorage.getPointer() == nullptr &&
2500  "bit width, initializer or captured type already set");
2501  InitStorage.setPointer(Init);
2502  }
2503 
2504  /// removeInClassInitializer - Remove the C++11 in-class initializer from this
2505  /// member.
2507  assert(hasInClassInitializer() && "no initializer to remove");
2508  InitStorage.setPointerAndInt(nullptr, ISK_BitWidthOrNothing);
2509  }
2510 
2511  /// \brief Determine whether this member captures the variable length array
2512  /// type.
2513  bool hasCapturedVLAType() const {
2514  return InitStorage.getInt() == ISK_CapturedVLAType;
2515  }
2516 
2517  /// \brief Get the captured variable length array type.
2519  return hasCapturedVLAType() ? static_cast<const VariableArrayType *>(
2520  InitStorage.getPointer())
2521  : nullptr;
2522  }
2523  /// \brief Set the captured variable length array type for this field.
2524  void setCapturedVLAType(const VariableArrayType *VLAType);
2525 
2526  /// getParent - Returns the parent of this field declaration, which
2527  /// is the struct in which this field is defined.
2528  const RecordDecl *getParent() const {
2529  return cast<RecordDecl>(getDeclContext());
2530  }
2531 
2533  return cast<RecordDecl>(getDeclContext());
2534  }
2535 
2536  SourceRange getSourceRange() const override LLVM_READONLY;
2537 
2538  /// Retrieves the canonical declaration of this field.
2539  FieldDecl *getCanonicalDecl() override { return getFirstDecl(); }
2540  const FieldDecl *getCanonicalDecl() const { return getFirstDecl(); }
2541 
2542  // Implement isa/cast/dyncast/etc.
2543  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2544  static bool classofKind(Kind K) { return K >= firstField && K <= lastField; }
2545 
2546  friend class ASTDeclReader;
2547  friend class ASTDeclWriter;
2548 };
2549 
2550 /// EnumConstantDecl - An instance of this object exists for each enum constant
2551 /// that is defined. For example, in "enum X {a,b}", each of a/b are
2552 /// EnumConstantDecl's, X is an instance of EnumDecl, and the type of a/b is a
2553 /// TagType for the X EnumDecl.
2554 class EnumConstantDecl : public ValueDecl, public Mergeable<EnumConstantDecl> {
2555  Stmt *Init; // an integer constant expression
2556  llvm::APSInt Val; // The value.
2557 protected:
2559  IdentifierInfo *Id, QualType T, Expr *E,
2560  const llvm::APSInt &V)
2561  : ValueDecl(EnumConstant, DC, L, Id, T), Init((Stmt*)E), Val(V) {}
2562 
2563 public:
2564 
2565  static EnumConstantDecl *Create(ASTContext &C, EnumDecl *DC,
2567  QualType T, Expr *E,
2568  const llvm::APSInt &V);
2569  static EnumConstantDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2570 
2571  const Expr *getInitExpr() const { return (const Expr*) Init; }
2572  Expr *getInitExpr() { return (Expr*) Init; }
2573  const llvm::APSInt &getInitVal() const { return Val; }
2574 
2575  void setInitExpr(Expr *E) { Init = (Stmt*) E; }
2576  void setInitVal(const llvm::APSInt &V) { Val = V; }
2577 
2578  SourceRange getSourceRange() const override LLVM_READONLY;
2579 
2580  /// Retrieves the canonical declaration of this enumerator.
2582  const EnumConstantDecl *getCanonicalDecl() const { return getFirstDecl(); }
2583 
2584  // Implement isa/cast/dyncast/etc.
2585  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2586  static bool classofKind(Kind K) { return K == EnumConstant; }
2587 
2588  friend class StmtIteratorBase;
2589 };
2590 
2591 /// IndirectFieldDecl - An instance of this class is created to represent a
2592 /// field injected from an anonymous union/struct into the parent scope.
2593 /// IndirectFieldDecl are always implicit.
2595  public Mergeable<IndirectFieldDecl> {
2596  void anchor() override;
2597  NamedDecl **Chaining;
2598  unsigned ChainingSize;
2599 
2603 
2604 public:
2608 
2609  static IndirectFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2610 
2612 
2614  return llvm::makeArrayRef(Chaining, ChainingSize);
2615  }
2616  chain_iterator chain_begin() const { return chain().begin(); }
2617  chain_iterator chain_end() const { return chain().end(); }
2618 
2619  unsigned getChainingSize() const { return ChainingSize; }
2620 
2622  assert(chain().size() >= 2);
2623  return cast<FieldDecl>(chain().back());
2624  }
2625 
2626  VarDecl *getVarDecl() const {
2627  assert(chain().size() >= 2);
2628  return dyn_cast<VarDecl>(chain().front());
2629  }
2630 
2632  const IndirectFieldDecl *getCanonicalDecl() const { return getFirstDecl(); }
2633 
2634  // Implement isa/cast/dyncast/etc.
2635  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2636  static bool classofKind(Kind K) { return K == IndirectField; }
2637  friend class ASTDeclReader;
2638 };
2639 
2640 /// TypeDecl - Represents a declaration of a type.
2641 ///
2642 class TypeDecl : public NamedDecl {
2643  void anchor() override;
2644  /// TypeForDecl - This indicates the Type object that represents
2645  /// this TypeDecl. It is a cache maintained by
2646  /// ASTContext::getTypedefType, ASTContext::getTagDeclType, and
2647  /// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl.
2648  mutable const Type *TypeForDecl;
2649  /// LocStart - The start of the source range for this declaration.
2650  SourceLocation LocStart;
2651  friend class ASTContext;
2652 
2653 protected:
2655  SourceLocation StartL = SourceLocation())
2656  : NamedDecl(DK, DC, L, Id), TypeForDecl(nullptr), LocStart(StartL) {}
2657 
2658 public:
2659  // Low-level accessor. If you just want the type defined by this node,
2660  // check out ASTContext::getTypeDeclType or one of
2661  // ASTContext::getTypedefType, ASTContext::getRecordType, etc. if you
2662  // already know the specific kind of node this is.
2663  const Type *getTypeForDecl() const { return TypeForDecl; }
2664  void setTypeForDecl(const Type *TD) { TypeForDecl = TD; }
2665 
2666  SourceLocation getLocStart() const LLVM_READONLY { return LocStart; }
2667  void setLocStart(SourceLocation L) { LocStart = L; }
2668  SourceRange getSourceRange() const override LLVM_READONLY {
2669  if (LocStart.isValid())
2670  return SourceRange(LocStart, getLocation());
2671  else
2672  return SourceRange(getLocation());
2673  }
2674 
2675  // Implement isa/cast/dyncast/etc.
2676  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2677  static bool classofKind(Kind K) { return K >= firstType && K <= lastType; }
2678 };
2679 
2680 
2681 /// Base class for declarations which introduce a typedef-name.
2682 class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
2683  void anchor() override;
2684  typedef std::pair<TypeSourceInfo*, QualType> ModedTInfo;
2685  llvm::PointerUnion<TypeSourceInfo*, ModedTInfo*> MaybeModedTInfo;
2686 
2687  // FIXME: This can be packed into the bitfields in Decl.
2688  /// If 0, we have not computed IsTransparentTag.
2689  /// Otherwise, IsTransparentTag is (CacheIsTransparentTag >> 1).
2690  mutable unsigned CacheIsTransparentTag : 2;
2691 
2692 protected:
2694  SourceLocation StartLoc, SourceLocation IdLoc,
2695  IdentifierInfo *Id, TypeSourceInfo *TInfo)
2696  : TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C),
2697  MaybeModedTInfo(TInfo), CacheIsTransparentTag(0) {}
2698 
2701  return getNextRedeclaration();
2702  }
2704  return getPreviousDecl();
2705  }
2707  return getMostRecentDecl();
2708  }
2709 
2710 public:
2712  typedef redeclarable_base::redecl_iterator redecl_iterator;
2719 
2720  bool isModed() const { return MaybeModedTInfo.is<ModedTInfo*>(); }
2721 
2723  return isModed()
2724  ? MaybeModedTInfo.get<ModedTInfo*>()->first
2725  : MaybeModedTInfo.get<TypeSourceInfo*>();
2726  }
2728  return isModed()
2729  ? MaybeModedTInfo.get<ModedTInfo*>()->second
2730  : MaybeModedTInfo.get<TypeSourceInfo*>()->getType();
2731  }
2733  MaybeModedTInfo = newType;
2734  }
2735  void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy) {
2736  MaybeModedTInfo = new (getASTContext()) ModedTInfo(unmodedTSI, modedTy);
2737  }
2738 
2739  /// Retrieves the canonical declaration of this typedef-name.
2741  const TypedefNameDecl *getCanonicalDecl() const { return getFirstDecl(); }
2742 
2743  /// Retrieves the tag declaration for which this is the typedef name for
2744  /// linkage purposes, if any.
2745  ///
2746  /// \param AnyRedecl Look for the tag declaration in any redeclaration of
2747  /// this typedef declaration.
2748  TagDecl *getAnonDeclWithTypedefName(bool AnyRedecl = false) const;
2749 
2750  /// Determines if this typedef shares a name and spelling location with its
2751  /// underlying tag type, as is the case with the NS_ENUM macro.
2752  bool isTransparentTag() const {
2753  if (CacheIsTransparentTag)
2754  return CacheIsTransparentTag & 0x2;
2755  return isTransparentTagSlow();
2756  }
2757 
2758  // Implement isa/cast/dyncast/etc.
2759  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2760  static bool classofKind(Kind K) {
2761  return K >= firstTypedefName && K <= lastTypedefName;
2762  }
2763 
2764 private:
2765  bool isTransparentTagSlow() const;
2766 };
2767 
2768 /// TypedefDecl - Represents the declaration of a typedef-name via the 'typedef'
2769 /// type specifier.
2772  SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
2773  : TypedefNameDecl(Typedef, C, DC, StartLoc, IdLoc, Id, TInfo) {}
2774 
2775 public:
2776  static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
2777  SourceLocation StartLoc, SourceLocation IdLoc,
2778  IdentifierInfo *Id, TypeSourceInfo *TInfo);
2779  static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2780 
2781  SourceRange getSourceRange() const override LLVM_READONLY;
2782 
2783  // Implement isa/cast/dyncast/etc.
2784  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2785  static bool classofKind(Kind K) { return K == Typedef; }
2786 };
2787 
2788 /// TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x
2789 /// alias-declaration.
2791  /// The template for which this is the pattern, if any.
2792  TypeAliasTemplateDecl *Template;
2793 
2795  SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
2796  : TypedefNameDecl(TypeAlias, C, DC, StartLoc, IdLoc, Id, TInfo),
2797  Template(nullptr) {}
2798 
2799 public:
2800  static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC,
2801  SourceLocation StartLoc, SourceLocation IdLoc,
2802  IdentifierInfo *Id, TypeSourceInfo *TInfo);
2803  static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2804 
2805  SourceRange getSourceRange() const override LLVM_READONLY;
2806 
2807  TypeAliasTemplateDecl *getDescribedAliasTemplate() const { return Template; }
2808  void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT) { Template = TAT; }
2809 
2810  // Implement isa/cast/dyncast/etc.
2811  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2812  static bool classofKind(Kind K) { return K == TypeAlias; }
2813 };
2814 
2815 /// TagDecl - Represents the declaration of a struct/union/class/enum.
2816 class TagDecl
2817  : public TypeDecl, public DeclContext, public Redeclarable<TagDecl> {
2818 public:
2819  // This is really ugly.
2821 
2822 private:
2823  // FIXME: This can be packed into the bitfields in Decl.
2824  /// TagDeclKind - The TagKind enum.
2825  unsigned TagDeclKind : 3;
2826 
2827  /// IsCompleteDefinition - True if this is a definition ("struct foo
2828  /// {};"), false if it is a declaration ("struct foo;"). It is not
2829  /// a definition until the definition has been fully processed.
2830  unsigned IsCompleteDefinition : 1;
2831 
2832 protected:
2833  /// IsBeingDefined - True if this is currently being defined.
2834  unsigned IsBeingDefined : 1;
2835 
2836 private:
2837  /// IsEmbeddedInDeclarator - True if this tag declaration is
2838  /// "embedded" (i.e., defined or declared for the very first time)
2839  /// in the syntax of a declarator.
2840  unsigned IsEmbeddedInDeclarator : 1;
2841 
2842  /// \brief True if this tag is free standing, e.g. "struct foo;".
2843  unsigned IsFreeStanding : 1;
2844 
2845 protected:
2846  // These are used by (and only defined for) EnumDecl.
2847  unsigned NumPositiveBits : 8;
2848  unsigned NumNegativeBits : 8;
2849 
2850  /// IsScoped - True if this tag declaration is a scoped enumeration. Only
2851  /// possible in C++11 mode.
2852  unsigned IsScoped : 1;
2853  /// IsScopedUsingClassTag - If this tag declaration is a scoped enum,
2854  /// then this is true if the scoped enum was declared using the class
2855  /// tag, false if it was declared with the struct tag. No meaning is
2856  /// associated if this tag declaration is not a scoped enum.
2857  unsigned IsScopedUsingClassTag : 1;
2858 
2859  /// IsFixed - True if this is an enumeration with fixed underlying type. Only
2860  /// possible in C++11, Microsoft extensions, or Objective C mode.
2861  unsigned IsFixed : 1;
2862 
2863  /// \brief Indicates whether it is possible for declarations of this kind
2864  /// to have an out-of-date definition.
2865  ///
2866  /// This option is only enabled when modules are enabled.
2867  unsigned MayHaveOutOfDateDef : 1;
2868 
2869  /// Has the full definition of this type been required by a use somewhere in
2870  /// the TU.
2871  unsigned IsCompleteDefinitionRequired : 1;
2872 private:
2873  SourceRange BraceRange;
2874 
2875  // A struct representing syntactic qualifier info,
2876  // to be used for the (uncommon) case of out-of-line declarations.
2877  typedef QualifierInfo ExtInfo;
2878 
2879  /// \brief If the (out-of-line) tag declaration name
2880  /// is qualified, it points to the qualifier info (nns and range);
2881  /// otherwise, if the tag declaration is anonymous and it is part of
2882  /// a typedef or alias, it points to the TypedefNameDecl (used for mangling);
2883  /// otherwise, if the tag declaration is anonymous and it is used as a
2884  /// declaration specifier for variables, it points to the first VarDecl (used
2885  /// for mangling);
2886  /// otherwise, it is a null (TypedefNameDecl) pointer.
2887  llvm::PointerUnion<TypedefNameDecl *, ExtInfo *> TypedefNameDeclOrQualifier;
2888 
2889  bool hasExtInfo() const { return TypedefNameDeclOrQualifier.is<ExtInfo *>(); }
2890  ExtInfo *getExtInfo() { return TypedefNameDeclOrQualifier.get<ExtInfo *>(); }
2891  const ExtInfo *getExtInfo() const {
2892  return TypedefNameDeclOrQualifier.get<ExtInfo *>();
2893  }
2894 
2895 protected:
2896  TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
2897  SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl,
2898  SourceLocation StartL)
2899  : TypeDecl(DK, DC, L, Id, StartL), DeclContext(DK), redeclarable_base(C),
2900  TagDeclKind(TK), IsCompleteDefinition(false), IsBeingDefined(false),
2901  IsEmbeddedInDeclarator(false), IsFreeStanding(false),
2902  IsCompleteDefinitionRequired(false),
2903  TypedefNameDeclOrQualifier((TypedefNameDecl *)nullptr) {
2904  assert((DK != Enum || TK == TTK_Enum) &&
2905  "EnumDecl not matched with TTK_Enum");
2906  setPreviousDecl(PrevDecl);
2907  }
2908 
2911  return getNextRedeclaration();
2912  }
2914  return getPreviousDecl();
2915  }
2917  return getMostRecentDecl();
2918  }
2919 
2920  /// @brief Completes the definition of this tag declaration.
2921  ///
2922  /// This is a helper function for derived classes.
2923  void completeDefinition();
2924 
2925 public:
2927  typedef redeclarable_base::redecl_iterator redecl_iterator;
2934 
2935  SourceRange getBraceRange() const { return BraceRange; }
2936  void setBraceRange(SourceRange R) { BraceRange = R; }
2937 
2938  /// getInnerLocStart - Return SourceLocation representing start of source
2939  /// range ignoring outer template declarations.
2941 
2942  /// getOuterLocStart - Return SourceLocation representing start of source
2943  /// range taking into account any outer template declarations.
2945  SourceRange getSourceRange() const override LLVM_READONLY;
2946 
2947  TagDecl *getCanonicalDecl() override;
2948  const TagDecl *getCanonicalDecl() const {
2949  return const_cast<TagDecl*>(this)->getCanonicalDecl();
2950  }
2951 
2952  /// isThisDeclarationADefinition() - Return true if this declaration
2953  /// is a completion definition of the type. Provided for consistency.
2955  return isCompleteDefinition();
2956  }
2957 
2958  /// isCompleteDefinition - Return true if this decl has its body
2959  /// fully specified.
2960  bool isCompleteDefinition() const {
2961  return IsCompleteDefinition;
2962  }
2963 
2964  /// \brief Return true if this complete decl is
2965  /// required to be complete for some existing use.
2967  return IsCompleteDefinitionRequired;
2968  }
2969 
2970  /// isBeingDefined - Return true if this decl is currently being defined.
2971  bool isBeingDefined() const {
2972  return IsBeingDefined;
2973  }
2974 
2975  bool isEmbeddedInDeclarator() const {
2976  return IsEmbeddedInDeclarator;
2977  }
2978  void setEmbeddedInDeclarator(bool isInDeclarator) {
2979  IsEmbeddedInDeclarator = isInDeclarator;
2980  }
2981 
2982  bool isFreeStanding() const { return IsFreeStanding; }
2983  void setFreeStanding(bool isFreeStanding = true) {
2984  IsFreeStanding = isFreeStanding;
2985  }
2986 
2987  /// \brief Whether this declaration declares a type that is
2988  /// dependent, i.e., a type that somehow depends on template
2989  /// parameters.
2990  bool isDependentType() const { return isDependentContext(); }
2991 
2992  /// @brief Starts the definition of this tag declaration.
2993  ///
2994  /// This method should be invoked at the beginning of the definition
2995  /// of this tag declaration. It will set the tag type into a state
2996  /// where it is in the process of being defined.
2997  void startDefinition();
2998 
2999  /// getDefinition - Returns the TagDecl that actually defines this
3000  /// struct/union/class/enum. When determining whether or not a
3001  /// struct/union/class/enum has a definition, one should use this
3002  /// method as opposed to 'isDefinition'. 'isDefinition' indicates
3003  /// whether or not a specific TagDecl is defining declaration, not
3004  /// whether or not the struct/union/class/enum type is defined.
3005  /// This method returns NULL if there is no TagDecl that defines
3006  /// the struct/union/class/enum.
3007  TagDecl *getDefinition() const;
3008 
3009  void setCompleteDefinition(bool V) { IsCompleteDefinition = V; }
3010 
3011  void setCompleteDefinitionRequired(bool V = true) {
3012  IsCompleteDefinitionRequired = V;
3013  }
3014 
3015  StringRef getKindName() const {
3016  return TypeWithKeyword::getTagTypeKindName(getTagKind());
3017  }
3018 
3020  return TagKind(TagDeclKind);
3021  }
3022 
3023  void setTagKind(TagKind TK) { TagDeclKind = TK; }
3024 
3025  bool isStruct() const { return getTagKind() == TTK_Struct; }
3026  bool isInterface() const { return getTagKind() == TTK_Interface; }
3027  bool isClass() const { return getTagKind() == TTK_Class; }
3028  bool isUnion() const { return getTagKind() == TTK_Union; }
3029  bool isEnum() const { return getTagKind() == TTK_Enum; }
3030 
3031  /// Is this tag type named, either directly or via being defined in
3032  /// a typedef of this type?
3033  ///
3034  /// C++11 [basic.link]p8:
3035  /// A type is said to have linkage if and only if:
3036  /// - it is a class or enumeration type that is named (or has a
3037  /// name for linkage purposes) and the name has linkage; ...
3038  /// C++11 [dcl.typedef]p9:
3039  /// If the typedef declaration defines an unnamed class (or enum),
3040  /// the first typedef-name declared by the declaration to be that
3041  /// class type (or enum type) is used to denote the class type (or
3042  /// enum type) for linkage purposes only.
3043  ///
3044  /// C does not have an analogous rule, but the same concept is
3045  /// nonetheless useful in some places.
3046  bool hasNameForLinkage() const {
3047  return (getDeclName() || getTypedefNameForAnonDecl());
3048  }
3049 
3051  return hasExtInfo() ? nullptr
3052  : TypedefNameDeclOrQualifier.get<TypedefNameDecl *>();
3053  }
3054 
3055  void setTypedefNameForAnonDecl(TypedefNameDecl *TDD);
3056 
3057  /// \brief Retrieve the nested-name-specifier that qualifies the name of this
3058  /// declaration, if it was present in the source.
3060  return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
3061  : nullptr;
3062  }
3063 
3064  /// \brief Retrieve the nested-name-specifier (with source-location
3065  /// information) that qualifies the name of this declaration, if it was
3066  /// present in the source.
3068  return hasExtInfo() ? getExtInfo()->QualifierLoc
3070  }
3071 
3072  void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
3073 
3074  unsigned getNumTemplateParameterLists() const {
3075  return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0;
3076  }
3078  assert(i < getNumTemplateParameterLists());
3079  return getExtInfo()->TemplParamLists[i];
3080  }
3083 
3084  // Implement isa/cast/dyncast/etc.
3085  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3086  static bool classofKind(Kind K) { return K >= firstTag && K <= lastTag; }
3087 
3089  return static_cast<DeclContext *>(const_cast<TagDecl*>(D));
3090  }
3092  return static_cast<TagDecl *>(const_cast<DeclContext*>(DC));
3093  }
3094 
3095  friend class ASTDeclReader;
3096  friend class ASTDeclWriter;
3097 };
3098 
3099 /// EnumDecl - Represents an enum. In C++11, enums can be forward-declared
3100 /// with a fixed underlying type, and in C we allow them to be forward-declared
3101 /// with no underlying type as an extension.
3102 class EnumDecl : public TagDecl {
3103  void anchor() override;
3104  /// IntegerType - This represent the integer type that the enum corresponds
3105  /// to for code generation purposes. Note that the enumerator constants may
3106  /// have a different type than this does.
3107  ///
3108  /// If the underlying integer type was explicitly stated in the source
3109  /// code, this is a TypeSourceInfo* for that type. Otherwise this type
3110  /// was automatically deduced somehow, and this is a Type*.
3111  ///
3112  /// Normally if IsFixed(), this would contain a TypeSourceInfo*, but in
3113  /// some cases it won't.
3114  ///
3115  /// The underlying type of an enumeration never has any qualifiers, so
3116  /// we can get away with just storing a raw Type*, and thus save an
3117  /// extra pointer when TypeSourceInfo is needed.
3118 
3119  llvm::PointerUnion<const Type*, TypeSourceInfo*> IntegerType;
3120 
3121  /// PromotionType - The integer type that values of this type should
3122  /// promote to. In C, enumerators are generally of an integer type
3123  /// directly, but gcc-style large enumerators (and all enumerators
3124  /// in C++) are of the enum type instead.
3125  QualType PromotionType;
3126 
3127  /// \brief If this enumeration is an instantiation of a member enumeration
3128  /// of a class template specialization, this is the member specialization
3129  /// information.
3130  MemberSpecializationInfo *SpecializationInfo;
3131 
3132  EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
3133  SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl,
3134  bool Scoped, bool ScopedUsingClassTag, bool Fixed)
3135  : TagDecl(Enum, TTK_Enum, C, DC, IdLoc, Id, PrevDecl, StartLoc),
3136  SpecializationInfo(nullptr) {
3137  assert(Scoped || !ScopedUsingClassTag);
3138  IntegerType = (const Type *)nullptr;
3139  NumNegativeBits = 0;
3140  NumPositiveBits = 0;
3141  IsScoped = Scoped;
3142  IsScopedUsingClassTag = ScopedUsingClassTag;
3143  IsFixed = Fixed;
3144  }
3145 
3146  void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED,
3148 public:
3150  return cast<EnumDecl>(TagDecl::getCanonicalDecl());
3151  }
3152  const EnumDecl *getCanonicalDecl() const {
3153  return const_cast<EnumDecl*>(this)->getCanonicalDecl();
3154  }
3155 
3157  return cast_or_null<EnumDecl>(
3158  static_cast<TagDecl *>(this)->getPreviousDecl());
3159  }
3160  const EnumDecl *getPreviousDecl() const {
3161  return const_cast<EnumDecl*>(this)->getPreviousDecl();
3162  }
3163 
3165  return cast<EnumDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl());
3166  }
3167  const EnumDecl *getMostRecentDecl() const {
3168  return const_cast<EnumDecl*>(this)->getMostRecentDecl();
3169  }
3170 
3172  return cast_or_null<EnumDecl>(TagDecl::getDefinition());
3173  }
3174 
3175  static EnumDecl *Create(ASTContext &C, DeclContext *DC,
3176  SourceLocation StartLoc, SourceLocation IdLoc,
3177  IdentifierInfo *Id, EnumDecl *PrevDecl,
3178  bool IsScoped, bool IsScopedUsingClassTag,
3179  bool IsFixed);
3180  static EnumDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3181 
3182  /// completeDefinition - When created, the EnumDecl corresponds to a
3183  /// forward-declared enum. This method is used to mark the
3184  /// declaration as being defined; it's enumerators have already been
3185  /// added (via DeclContext::addDecl). NewType is the new underlying
3186  /// type of the enumeration type.
3187  void completeDefinition(QualType NewType,
3188  QualType PromotionType,
3189  unsigned NumPositiveBits,
3190  unsigned NumNegativeBits);
3191 
3192  // enumerator_iterator - Iterates through the enumerators of this
3193  // enumeration.
3195  typedef llvm::iterator_range<specific_decl_iterator<EnumConstantDecl>>
3197 
3199  return enumerator_range(enumerator_begin(), enumerator_end());
3200  }
3201 
3203  const EnumDecl *E = getDefinition();
3204  if (!E)
3205  E = this;
3206  return enumerator_iterator(E->decls_begin());
3207  }
3208 
3210  const EnumDecl *E = getDefinition();
3211  if (!E)
3212  E = this;
3213  return enumerator_iterator(E->decls_end());
3214  }
3215 
3216  /// getPromotionType - Return the integer type that enumerators
3217  /// should promote to.
3218  QualType getPromotionType() const { return PromotionType; }
3219 
3220  /// \brief Set the promotion type.
3221  void setPromotionType(QualType T) { PromotionType = T; }
3222 
3223  /// getIntegerType - Return the integer type this enum decl corresponds to.
3224  /// This returns a null QualType for an enum forward definition with no fixed
3225  /// underlying type.
3227  if (!IntegerType)
3228  return QualType();
3229  if (const Type *T = IntegerType.dyn_cast<const Type*>())
3230  return QualType(T, 0);
3231  return IntegerType.get<TypeSourceInfo*>()->getType().getUnqualifiedType();
3232  }
3233 
3234  /// \brief Set the underlying integer type.
3235  void setIntegerType(QualType T) { IntegerType = T.getTypePtrOrNull(); }
3236 
3237  /// \brief Set the underlying integer type source info.
3238  void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo) { IntegerType = TInfo; }
3239 
3240  /// \brief Return the type source info for the underlying integer type,
3241  /// if no type source info exists, return 0.
3243  return IntegerType.dyn_cast<TypeSourceInfo*>();
3244  }
3245 
3246  /// \brief Retrieve the source range that covers the underlying type if
3247  /// specified.
3248  SourceRange getIntegerTypeRange() const LLVM_READONLY;
3249 
3250  /// \brief Returns the width in bits required to store all the
3251  /// non-negative enumerators of this enum.
3252  unsigned getNumPositiveBits() const {
3253  return NumPositiveBits;
3254  }
3255  void setNumPositiveBits(unsigned Num) {
3256  NumPositiveBits = Num;
3257  assert(NumPositiveBits == Num && "can't store this bitcount");
3258  }
3259 
3260  /// \brief Returns the width in bits required to store all the
3261  /// negative enumerators of this enum. These widths include
3262  /// the rightmost leading 1; that is:
3263  ///
3264  /// MOST NEGATIVE ENUMERATOR PATTERN NUM NEGATIVE BITS
3265  /// ------------------------ ------- -----------------
3266  /// -1 1111111 1
3267  /// -10 1110110 5
3268  /// -101 1001011 8
3269  unsigned getNumNegativeBits() const {
3270  return NumNegativeBits;
3271  }
3272  void setNumNegativeBits(unsigned Num) {
3273  NumNegativeBits = Num;
3274  }
3275 
3276  /// \brief Returns true if this is a C++11 scoped enumeration.
3277  bool isScoped() const {
3278  return IsScoped;
3279  }
3280 
3281  /// \brief Returns true if this is a C++11 scoped enumeration.
3282  bool isScopedUsingClassTag() const {
3283  return IsScopedUsingClassTag;
3284  }
3285 
3286  /// \brief Returns true if this is an Objective-C, C++11, or
3287  /// Microsoft-style enumeration with a fixed underlying type.
3288  bool isFixed() const {
3289  return IsFixed;
3290  }
3291 
3292  /// \brief Returns true if this can be considered a complete type.
3293  bool isComplete() const {
3294  return isCompleteDefinition() || isFixed();
3295  }
3296 
3297  /// Returns true if this enum is either annotated with
3298  /// enum_extensibility(closed) or isn't annotated with enum_extensibility.
3299  bool isClosed() const;
3300 
3301  /// Returns true if this enum is annotated with flag_enum and isn't annotated
3302  /// with enum_extensibility(open).
3303  bool isClosedFlag() const;
3304 
3305  /// Returns true if this enum is annotated with neither flag_enum nor
3306  /// enum_extensibility(open).
3307  bool isClosedNonFlag() const;
3308 
3309  /// \brief Retrieve the enum definition from which this enumeration could
3310  /// be instantiated, if it is an instantiation (rather than a non-template).
3312 
3313  /// \brief Returns the enumeration (declared within the template)
3314  /// from which this enumeration type was instantiated, or NULL if
3315  /// this enumeration was not instantiated from any template.
3316  EnumDecl *getInstantiatedFromMemberEnum() const;
3317 
3318  /// \brief If this enumeration is a member of a specialization of a
3319  /// templated class, determine what kind of template specialization
3320  /// or instantiation this is.
3322 
3323  /// \brief For an enumeration member that was instantiated from a member
3324  /// enumeration of a templated class, set the template specialiation kind.
3326  SourceLocation PointOfInstantiation = SourceLocation());
3327 
3328  /// \brief If this enumeration is an instantiation of a member enumeration of
3329  /// a class template specialization, retrieves the member specialization
3330  /// information.
3332  return SpecializationInfo;
3333  }
3334 
3335  /// \brief Specify that this enumeration is an instantiation of the
3336  /// member enumeration ED.
3339  setInstantiationOfMemberEnum(getASTContext(), ED, TSK);
3340  }
3341 
3342  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3343  static bool classofKind(Kind K) { return K == Enum; }
3344 
3345  friend class ASTDeclReader;
3346 };
3347 
3348 
3349 /// RecordDecl - Represents a struct/union/class. For example:
3350 /// struct X; // Forward declaration, no "body".
3351 /// union Y { int A, B; }; // Has body with members A and B (FieldDecls).
3352 /// This decl will be marked invalid if *any* members are invalid.
3353 ///
3354 class RecordDecl : public TagDecl {
3355  // FIXME: This can be packed into the bitfields in Decl.
3356  /// HasFlexibleArrayMember - This is true if this struct ends with a flexible
3357  /// array member (e.g. int X[]) or if this union contains a struct that does.
3358  /// If so, this cannot be contained in arrays or other structs as a member.
3359  bool HasFlexibleArrayMember : 1;
3360 
3361  /// AnonymousStructOrUnion - Whether this is the type of an anonymous struct
3362  /// or union.
3363  bool AnonymousStructOrUnion : 1;
3364 
3365  /// HasObjectMember - This is true if this struct has at least one member
3366  /// containing an Objective-C object pointer type.
3367  bool HasObjectMember : 1;
3368 
3369  /// HasVolatileMember - This is true if struct has at least one member of
3370  /// 'volatile' type.
3371  bool HasVolatileMember : 1;
3372 
3373  /// \brief Whether the field declarations of this record have been loaded
3374  /// from external storage. To avoid unnecessary deserialization of
3375  /// methods/nested types we allow deserialization of just the fields
3376  /// when needed.
3377  mutable bool LoadedFieldsFromExternalStorage : 1;
3378  friend class DeclContext;
3379 
3380 protected:
3381  RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
3382  SourceLocation StartLoc, SourceLocation IdLoc,
3383  IdentifierInfo *Id, RecordDecl *PrevDecl);
3384 
3385 public:
3386  static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
3387  SourceLocation StartLoc, SourceLocation IdLoc,
3388  IdentifierInfo *Id, RecordDecl* PrevDecl = nullptr);
3389  static RecordDecl *CreateDeserialized(const ASTContext &C, unsigned ID);
3390 
3392  return cast_or_null<RecordDecl>(
3393  static_cast<TagDecl *>(this)->getPreviousDecl());
3394  }
3395  const RecordDecl *getPreviousDecl() const {
3396  return const_cast<RecordDecl*>(this)->getPreviousDecl();
3397  }
3398 
3400  return cast<RecordDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl());
3401  }
3403  return const_cast<RecordDecl*>(this)->getMostRecentDecl();
3404  }
3405 
3406  bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; }
3407  void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; }
3408 
3409  /// isAnonymousStructOrUnion - Whether this is an anonymous struct
3410  /// or union. To be an anonymous struct or union, it must have been
3411  /// declared without a name and there must be no objects of this
3412  /// type declared, e.g.,
3413  /// @code
3414  /// union { int i; float f; };
3415  /// @endcode
3416  /// is an anonymous union but neither of the following are:
3417  /// @code
3418  /// union X { int i; float f; };
3419  /// union { int i; float f; } obj;
3420  /// @endcode
3421  bool isAnonymousStructOrUnion() const { return AnonymousStructOrUnion; }
3422  void setAnonymousStructOrUnion(bool Anon) {
3423  AnonymousStructOrUnion = Anon;
3424  }
3425 
3426  bool hasObjectMember() const { return HasObjectMember; }
3427  void setHasObjectMember (bool val) { HasObjectMember = val; }
3428 
3429  bool hasVolatileMember() const { return HasVolatileMember; }
3430  void setHasVolatileMember (bool val) { HasVolatileMember = val; }
3431 
3433  return LoadedFieldsFromExternalStorage;
3434  }
3436  LoadedFieldsFromExternalStorage = val;
3437  }
3438 
3439  /// \brief Determines whether this declaration represents the
3440  /// injected class name.
3441  ///
3442  /// The injected class name in C++ is the name of the class that
3443  /// appears inside the class itself. For example:
3444  ///
3445  /// \code
3446  /// struct C {
3447  /// // C is implicitly declared here as a synonym for the class name.
3448  /// };
3449  ///
3450  /// C::C c; // same as "C c;"
3451  /// \endcode
3452  bool isInjectedClassName() const;
3453 
3454  /// \brief Determine whether this record is a class describing a lambda
3455  /// function object.
3456  bool isLambda() const;
3457 
3458  /// \brief Determine whether this record is a record for captured variables in
3459  /// CapturedStmt construct.
3460  bool isCapturedRecord() const;
3461  /// \brief Mark the record as a record for captured variables in CapturedStmt
3462  /// construct.
3463  void setCapturedRecord();
3464 
3465  /// getDefinition - Returns the RecordDecl that actually defines
3466  /// this struct/union/class. When determining whether or not a
3467  /// struct/union/class is completely defined, one should use this
3468  /// method as opposed to 'isCompleteDefinition'.
3469  /// 'isCompleteDefinition' indicates whether or not a specific
3470  /// RecordDecl is a completed definition, not whether or not the
3471  /// record type is defined. This method returns NULL if there is
3472  /// no RecordDecl that defines the struct/union/tag.
3474  return cast_or_null<RecordDecl>(TagDecl::getDefinition());
3475  }
3476 
3477  // Iterator access to field members. The field iterator only visits
3478  // the non-static data members of this class, ignoring any static
3479  // data members, functions, constructors, destructors, etc.
3481  typedef llvm::iterator_range<specific_decl_iterator<FieldDecl>> field_range;
3482 
3483  field_range fields() const { return field_range(field_begin(), field_end()); }
3484  field_iterator field_begin() const;
3485 
3487  return field_iterator(decl_iterator());
3488  }
3489 
3490  // field_empty - Whether there are any fields (non-static data
3491  // members) in this record.
3492  bool field_empty() const {
3493  return field_begin() == field_end();
3494  }
3495 
3496  /// completeDefinition - Notes that the definition of this type is
3497  /// now complete.
3498  virtual void completeDefinition();
3499 
3500  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3501  static bool classofKind(Kind K) {
3502  return K >= firstRecord && K <= lastRecord;
3503  }
3504 
3505  /// isMsStrust - Get whether or not this is an ms_struct which can
3506  /// be turned on with an attribute, pragma, or -mms-bitfields
3507  /// commandline option.
3508  bool isMsStruct(const ASTContext &C) const;
3509 
3510  /// \brief Whether we are allowed to insert extra padding between fields.
3511  /// These padding are added to help AddressSanitizer detect
3512  /// intra-object-overflow bugs.
3513  bool mayInsertExtraPadding(bool EmitRemark = false) const;
3514 
3515  /// Finds the first data member which has a name.
3516  /// nullptr is returned if no named data member exists.
3517  const FieldDecl *findFirstNamedDataMember() const;
3518 
3519 private:
3520  /// \brief Deserialize just the fields.
3521  void LoadFieldsFromExternalStorage() const;
3522 };
3523 
3524 class FileScopeAsmDecl : public Decl {
3525  virtual void anchor();
3526  StringLiteral *AsmString;
3527  SourceLocation RParenLoc;
3528  FileScopeAsmDecl(DeclContext *DC, StringLiteral *asmstring,
3529  SourceLocation StartL, SourceLocation EndL)
3530  : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
3531 public:
3533  StringLiteral *Str, SourceLocation AsmLoc,
3534  SourceLocation RParenLoc);
3535 
3536  static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3537 
3538  SourceLocation getAsmLoc() const { return getLocation(); }
3539  SourceLocation getRParenLoc() const { return RParenLoc; }
3540  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3541  SourceRange getSourceRange() const override LLVM_READONLY {
3542  return SourceRange(getAsmLoc(), getRParenLoc());
3543  }
3544 
3545  const StringLiteral *getAsmString() const { return AsmString; }
3546  StringLiteral *getAsmString() { return AsmString; }
3547  void setAsmString(StringLiteral *Asm) { AsmString = Asm; }
3548 
3549  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3550  static bool classofKind(Kind K) { return K == FileScopeAsm; }
3551 };
3552 
3553 /// BlockDecl - This represents a block literal declaration, which is like an
3554 /// unnamed FunctionDecl. For example:
3555 /// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
3556 ///
3557 class BlockDecl : public Decl, public DeclContext {
3558 public:
3559  /// A class which contains all the information about a particular
3560  /// captured value.
3561  class Capture {
3562  enum {
3563  flag_isByRef = 0x1,
3564  flag_isNested = 0x2
3565  };
3566 
3567  /// The variable being captured.
3568  llvm::PointerIntPair<VarDecl*, 2> VariableAndFlags;
3569 
3570  /// The copy expression, expressed in terms of a DeclRef (or
3571  /// BlockDeclRef) to the captured variable. Only required if the
3572  /// variable has a C++ class type.
3573  Expr *CopyExpr;
3574 
3575  public:
3576  Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
3577  : VariableAndFlags(variable,
3578  (byRef ? flag_isByRef : 0) | (nested ? flag_isNested : 0)),
3579  CopyExpr(copy) {}
3580 
3581  /// The variable being captured.
3582  VarDecl *getVariable() const { return VariableAndFlags.getPointer(); }
3583 
3584  /// Whether this is a "by ref" capture, i.e. a capture of a __block
3585  /// variable.
3586  bool isByRef() const { return VariableAndFlags.getInt() & flag_isByRef; }
3587 
3588  /// Whether this is a nested capture, i.e. the variable captured
3589  /// is not from outside the immediately enclosing function/block.
3590  bool isNested() const { return VariableAndFlags.getInt() & flag_isNested; }
3591 
3592  bool hasCopyExpr() const { return CopyExpr != nullptr; }
3593  Expr *getCopyExpr() const { return CopyExpr; }
3594  void setCopyExpr(Expr *e) { CopyExpr = e; }
3595  };
3596 
3597 private:
3598  // FIXME: This can be packed into the bitfields in Decl.
3599  bool IsVariadic : 1;
3600  bool CapturesCXXThis : 1;
3601  bool BlockMissingReturnType : 1;
3602  bool IsConversionFromLambda : 1;
3603  /// ParamInfo - new[]'d array of pointers to ParmVarDecls for the formal
3604  /// parameters of this function. This is null if a prototype or if there are
3605  /// no formals.
3606  ParmVarDecl **ParamInfo;
3607  unsigned NumParams;
3608 
3609  Stmt *Body;
3610  TypeSourceInfo *SignatureAsWritten;
3611 
3612  const Capture *Captures;
3613  unsigned NumCaptures;
3614 
3615  unsigned ManglingNumber;
3616  Decl *ManglingContextDecl;
3617 
3618 protected:
3620  : Decl(Block, DC, CaretLoc), DeclContext(Block),
3621  IsVariadic(false), CapturesCXXThis(false),
3622  BlockMissingReturnType(true), IsConversionFromLambda(false),
3623  ParamInfo(nullptr), NumParams(0), Body(nullptr),
3624  SignatureAsWritten(nullptr), Captures(nullptr), NumCaptures(0),
3625  ManglingNumber(0), ManglingContextDecl(nullptr) {}
3626 
3627 public:
3628  static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L);
3629  static BlockDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3630 
3632 
3633  bool isVariadic() const { return IsVariadic; }
3634  void setIsVariadic(bool value) { IsVariadic = value; }
3635 
3636  CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; }
3637  Stmt *getBody() const override { return (Stmt*) Body; }
3638  void setBody(CompoundStmt *B) { Body = (Stmt*) B; }
3639 
3640  void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; }
3641  TypeSourceInfo *getSignatureAsWritten() const { return SignatureAsWritten; }
3642 
3643  // ArrayRef access to formal parameters.
3645  return {ParamInfo, getNumParams()};
3646  }
3648  return {ParamInfo, getNumParams()};
3649  }
3650 
3651  // Iterator access to formal parameters.
3654  bool param_empty() const { return parameters().empty(); }
3655  param_iterator param_begin() { return parameters().begin(); }
3656  param_iterator param_end() { return parameters().end(); }
3657  param_const_iterator param_begin() const { return parameters().begin(); }
3658  param_const_iterator param_end() const { return parameters().end(); }
3659  size_t param_size() const { return parameters().size(); }
3660 
3661  unsigned getNumParams() const { return NumParams; }
3662  const ParmVarDecl *getParamDecl(unsigned i) const {
3663  assert(i < getNumParams() && "Illegal param #");
3664  return ParamInfo[i];
3665  }
3666  ParmVarDecl *getParamDecl(unsigned i) {
3667  assert(i < getNumParams() && "Illegal param #");
3668  return ParamInfo[i];
3669  }
3670  void setParams(ArrayRef<ParmVarDecl *> NewParamInfo);
3671 
3672  /// hasCaptures - True if this block (or its nested blocks) captures
3673  /// anything of local storage from its enclosing scopes.
3674  bool hasCaptures() const { return NumCaptures != 0 || CapturesCXXThis; }
3675 
3676  /// getNumCaptures - Returns the number of captured variables.
3677  /// Does not include an entry for 'this'.
3678  unsigned getNumCaptures() const { return NumCaptures; }
3679 
3681 
3682  ArrayRef<Capture> captures() const { return {Captures, NumCaptures}; }
3683 
3684  capture_const_iterator capture_begin() const { return captures().begin(); }
3685  capture_const_iterator capture_end() const { return captures().end(); }
3686 
3687  bool capturesCXXThis() const { return CapturesCXXThis; }
3688  bool blockMissingReturnType() const { return BlockMissingReturnType; }
3689  void setBlockMissingReturnType(bool val) { BlockMissingReturnType = val; }
3690 
3691  bool isConversionFromLambda() const { return IsConversionFromLambda; }
3692  void setIsConversionFromLambda(bool val) { IsConversionFromLambda = val; }
3693 
3694  bool capturesVariable(const VarDecl *var) const;
3695 
3696  void setCaptures(ASTContext &Context, ArrayRef<Capture> Captures,
3697  bool CapturesCXXThis);
3698 
3699  unsigned getBlockManglingNumber() const {
3700  return ManglingNumber;
3701  }
3703  return ManglingContextDecl;
3704  }
3705 
3706  void setBlockMangling(unsigned Number, Decl *Ctx) {
3707  ManglingNumber = Number;
3708  ManglingContextDecl = Ctx;
3709  }
3710 
3711  SourceRange getSourceRange() const override LLVM_READONLY;
3712 
3713  // Implement isa/cast/dyncast/etc.
3714  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3715  static bool classofKind(Kind K) { return K == Block; }
3717  return static_cast<DeclContext *>(const_cast<BlockDecl*>(D));
3718  }
3720  return static_cast<BlockDecl *>(const_cast<DeclContext*>(DC));
3721  }
3722 };
3723 
3724 /// \brief This represents the body of a CapturedStmt, and serves as its
3725 /// DeclContext.
3726 class CapturedDecl final
3727  : public Decl,
3728  public DeclContext,
3729  private llvm::TrailingObjects<CapturedDecl, ImplicitParamDecl *> {
3730 protected:
3731  size_t numTrailingObjects(OverloadToken<ImplicitParamDecl>) {
3732  return NumParams;
3733  }
3734 
3735 private:
3736  /// \brief The number of parameters to the outlined function.
3737  unsigned NumParams;
3738  /// \brief The position of context parameter in list of parameters.
3739  unsigned ContextParam;
3740  /// \brief The body of the outlined function.
3741  llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow;
3742 
3743  explicit CapturedDecl(DeclContext *DC, unsigned NumParams);
3744 
3745  ImplicitParamDecl *const *getParams() const {
3746  return getTrailingObjects<ImplicitParamDecl *>();
3747  }
3748 
3749  ImplicitParamDecl **getParams() {
3750  return getTrailingObjects<ImplicitParamDecl *>();
3751  }
3752 
3753 public:
3754  static CapturedDecl *Create(ASTContext &C, DeclContext *DC,
3755  unsigned NumParams);
3756  static CapturedDecl *CreateDeserialized(ASTContext &C, unsigned ID,
3757  unsigned NumParams);
3758 
3759  Stmt *getBody() const override;
3760  void setBody(Stmt *B);
3761 
3762  bool isNothrow() const;
3763  void setNothrow(bool Nothrow = true);
3764 
3765  unsigned getNumParams() const { return NumParams; }
3766 
3767  ImplicitParamDecl *getParam(unsigned i) const {
3768  assert(i < NumParams);
3769  return getParams()[i];
3770  }
3771  void setParam(unsigned i, ImplicitParamDecl *P) {
3772  assert(i < NumParams);
3773  getParams()[i] = P;
3774  }
3775 
3776  // ArrayRef interface to parameters.
3778  return {getParams(), getNumParams()};
3779  }
3781  return {getParams(), getNumParams()};
3782  }
3783 
3784  /// \brief Retrieve the parameter containing captured variables.
3786  assert(ContextParam < NumParams);
3787  return getParam(ContextParam);
3788  }
3789  void setContextParam(unsigned i, ImplicitParamDecl *P) {
3790  assert(i < NumParams);
3791  ContextParam = i;
3792  setParam(i, P);
3793  }
3794  unsigned getContextParamPosition() const { return ContextParam; }
3795 
3797  typedef llvm::iterator_range<param_iterator> param_range;
3798 
3799  /// \brief Retrieve an iterator pointing to the first parameter decl.
3800  param_iterator param_begin() const { return getParams(); }
3801  /// \brief Retrieve an iterator one past the last parameter decl.
3802  param_iterator param_end() const { return getParams() + NumParams; }
3803 
3804  // Implement isa/cast/dyncast/etc.
3805  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3806  static bool classofKind(Kind K) { return K == Captured; }
3808  return static_cast<DeclContext *>(const_cast<CapturedDecl *>(D));
3809  }
3811  return static_cast<CapturedDecl *>(const_cast<DeclContext *>(DC));
3812  }
3813 
3814  friend class ASTDeclReader;
3815  friend class ASTDeclWriter;
3817 };
3818 
3819 /// \brief Describes a module import declaration, which makes the contents
3820 /// of the named module visible in the current translation unit.
3821 ///
3822 /// An import declaration imports the named module (or submodule). For example:
3823 /// \code
3824 /// @import std.vector;
3825 /// \endcode
3826 ///
3827 /// Import declarations can also be implicitly generated from
3828 /// \#include/\#import directives.
3829 class ImportDecl final : public Decl,
3830  llvm::TrailingObjects<ImportDecl, SourceLocation> {
3831  /// \brief The imported module, along with a bit that indicates whether
3832  /// we have source-location information for each identifier in the module
3833  /// name.
3834  ///
3835  /// When the bit is false, we only have a single source location for the
3836  /// end of the import declaration.
3837  llvm::PointerIntPair<Module *, 1, bool> ImportedAndComplete;
3838 
3839  /// \brief The next import in the list of imports local to the translation
3840  /// unit being parsed (not loaded from an AST file).
3841  ImportDecl *NextLocalImport;
3842 
3843  friend class ASTReader;
3844  friend class ASTDeclReader;
3845  friend class ASTContext;
3846  friend TrailingObjects;
3847 
3848  ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported,
3849  ArrayRef<SourceLocation> IdentifierLocs);
3850 
3851  ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported,
3852  SourceLocation EndLoc);
3853 
3854  ImportDecl(EmptyShell Empty) : Decl(Import, Empty), NextLocalImport() { }
3855 
3856 public:
3857  /// \brief Create a new module import declaration.
3858  static ImportDecl *Create(ASTContext &C, DeclContext *DC,
3859  SourceLocation StartLoc, Module *Imported,
3860  ArrayRef<SourceLocation> IdentifierLocs);
3861 
3862  /// \brief Create a new module import declaration for an implicitly-generated
3863  /// import.
3864  static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC,
3865  SourceLocation StartLoc, Module *Imported,
3866  SourceLocation EndLoc);
3867 
3868  /// \brief Create a new, deserialized module import declaration.
3869  static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID,
3870  unsigned NumLocations);
3871 
3872  /// \brief Retrieve the module that was imported by the import declaration.
3873  Module *getImportedModule() const { return ImportedAndComplete.getPointer(); }
3874 
3875  /// \brief Retrieves the locations of each of the identifiers that make up
3876  /// the complete module name in the import declaration.
3877  ///
3878  /// This will return an empty array if the locations of the individual
3879  /// identifiers aren't available.
3880  ArrayRef<SourceLocation> getIdentifierLocs() const;
3881 
3882  SourceRange getSourceRange() const override LLVM_READONLY;
3883 
3884  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3885  static bool classofKind(Kind K) { return K == Import; }
3886 };
3887 
3888 /// \brief Represents a C++ Modules TS module export declaration.
3889 ///
3890 /// For example:
3891 /// \code
3892 /// export void foo();
3893 /// \endcode
3894 class ExportDecl final : public Decl, public DeclContext {
3895  virtual void anchor();
3896 private:
3897  /// \brief The source location for the right brace (if valid).
3898  SourceLocation RBraceLoc;
3899 
3900  ExportDecl(DeclContext *DC, SourceLocation ExportLoc)
3901  : Decl(Export, DC, ExportLoc), DeclContext(Export),
3902  RBraceLoc(SourceLocation()) { }
3903 
3904  friend class ASTDeclReader;
3905 
3906 public:
3907  static ExportDecl *Create(ASTContext &C, DeclContext *DC,
3908  SourceLocation ExportLoc);
3909  static ExportDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3910 
3912  SourceLocation getRBraceLoc() const { return RBraceLoc; }
3913  void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
3914 
3915  SourceLocation getLocEnd() const LLVM_READONLY {
3916  if (RBraceLoc.isValid())
3917  return RBraceLoc;
3918  // No braces: get the end location of the (only) declaration in context
3919  // (if present).
3920  return decls_empty() ? getLocation() : decls_begin()->getLocEnd();
3921  }
3922 
3923  SourceRange getSourceRange() const override LLVM_READONLY {
3924  return SourceRange(getLocation(), getLocEnd());
3925  }
3926 
3927  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3928  static bool classofKind(Kind K) { return K == Export; }
3930  return static_cast<DeclContext *>(const_cast<ExportDecl*>(D));
3931  }
3933  return static_cast<ExportDecl *>(const_cast<DeclContext*>(DC));
3934  }
3935 };
3936 
3937 /// \brief Represents an empty-declaration.
3938 class EmptyDecl : public Decl {
3939  virtual void anchor();
3941  : Decl(Empty, DC, L) { }
3942 
3943 public:
3944  static EmptyDecl *Create(ASTContext &C, DeclContext *DC,
3945  SourceLocation L);
3946  static EmptyDecl *CreateDeserialized(ASTContext &C, unsigned ID);
3947 
3948  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3949  static bool classofKind(Kind K) { return K == Empty; }
3950 };
3951 
3952 /// Insertion operator for diagnostics. This allows sending NamedDecl's
3953 /// into a diagnostic with <<.
3955  const NamedDecl* ND) {
3956  DB.AddTaggedVal(reinterpret_cast<intptr_t>(ND),
3958  return DB;
3959 }
3961  const NamedDecl* ND) {
3962  PD.AddTaggedVal(reinterpret_cast<intptr_t>(ND),
3964  return PD;
3965 }
3966 
3967 template<typename decl_type>
3968 void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) {
3969  // Note: This routine is implemented here because we need both NamedDecl
3970  // and Redeclarable to be defined.
3971  assert(RedeclLink.NextIsLatest() &&
3972  "setPreviousDecl on a decl already in a redeclaration chain");
3973 
3974  if (PrevDecl) {
3975  // Point to previous. Make sure that this is actually the most recent
3976  // redeclaration, or we can build invalid chains. If the most recent
3977  // redeclaration is invalid, it won't be PrevDecl, but we want it anyway.
3978  First = PrevDecl->getFirstDecl();
3979  assert(First->RedeclLink.NextIsLatest() && "Expected first");
3980  decl_type *MostRecent = First->getNextRedeclaration();
3981  RedeclLink = PreviousDeclLink(cast<decl_type>(MostRecent));
3982 
3983  // If the declaration was previously visible, a redeclaration of it remains
3984  // visible even if it wouldn't be visible by itself.
3985  static_cast<decl_type*>(this)->IdentifierNamespace |=
3986  MostRecent->getIdentifierNamespace() &
3988  } else {
3989  // Make this first.
3990  First = static_cast<decl_type*>(this);
3991  }
3992 
3993  // First one will point to this one as latest.
3994  First->RedeclLink.setLatest(static_cast<decl_type*>(this));
3995 
3996  assert(!isa<NamedDecl>(static_cast<decl_type*>(this)) ||
3997  cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid());
3998 }
3999 
4000 // Inline function definitions.
4001 
4002 /// \brief Check if the given decl is complete.
4003 ///
4004 /// We use this function to break a cycle between the inline definitions in
4005 /// Type.h and Decl.h.
4006 inline bool IsEnumDeclComplete(EnumDecl *ED) {
4007  return ED->isComplete();
4008 }
4009 
4010 /// \brief Check if the given decl is scoped.
4011 ///
4012 /// We use this function to break a cycle between the inline definitions in
4013 /// Type.h and Decl.h.
4014 inline bool IsEnumDeclScoped(EnumDecl *ED) {
4015  return ED->isScoped();
4016 }
4017 
4018 } // end namespace clang
4019 
4020 #endif
static bool classof(const Decl *D)
Definition: Decl.h:3085
static bool classofKind(Kind K)
Definition: Decl.h:3949
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
Definition: DeclCXX.cpp:2228
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3541
void setHasSkippedBody(bool Skipped=true)
Definition: Decl.h:2050
llvm::iterator_range< specific_decl_iterator< FieldDecl > > field_range
Definition: Decl.h:3481
FunctionDecl * getDefinition()
Get the definition for this declaration.
Definition: Decl.h:1844
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1467
void setOwningFunction(DeclContext *FD)
setOwningFunction - Sets the function declaration that owns this ParmVarDecl.
Definition: Decl.h:1580
static unsigned getFieldIndex(Decl *F)
ObjCStringFormatFamily
void setImplicit(bool I=true)
Definition: DeclBase.h:538
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
Parameter for captured context.
Definition: Decl.h:1395
static bool classof(const Decl *D)
Definition: Decl.h:597
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:237
static DeclContext * castToDeclContext(const ExternCContextDecl *D)
Definition: Decl.h:203
void setAnonymousStructOrUnion(bool Anon)
Definition: Decl.h:3422
A class which contains all the information about a particular captured value.
Definition: Decl.h:3561
ArrayRef< NamedDecl * >::const_iterator chain_iterator
Definition: Decl.h:2611
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
Definition: Decl.cpp:2195
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition: Decl.cpp:2363
A (possibly-)qualified type.
Definition: Type.h:616
ArrayRef< Capture > captures() const
Definition: Decl.h:3682
Static storage duration.
Definition: Specifiers.h:276
static bool classofKind(Kind K)
Definition: Decl.h:202
param_const_iterator param_end() const
Definition: Decl.h:3658
bool isVariadic() const
Definition: Decl.h:3633
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2434
bool isByRef() const
Whether this is a "by ref" capture, i.e.
Definition: Decl.h:3586
StringRef getMSAsmLabel() const
Definition: Decl.h:452
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Definition: Decl.h:2121
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
Definition: Decl.h:371
static bool classofKind(Kind K)
Definition: Decl.h:401
Expr * getInitExpr()
Definition: Decl.h:2572
static VarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:1865
QualifierInfo()
Default constructor.
Definition: Decl.h:620
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Definition: Decl.h:232
static TranslationUnitDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:102
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Definition: Decl.cpp:2521
bool IsEnumDeclScoped(EnumDecl *ED)
Check if the given decl is scoped.
Definition: Decl.h:4014
static bool classofKind(Kind K)
Definition: Decl.h:3550
Stmt - This represents one statement.
Definition: Stmt.h:60
param_const_iterator param_begin() const
Definition: Decl.h:2079
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3288
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity, such as 'alias' or 'ifunc'.
Definition: DeclBase.cpp:441
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
Definition: Decl.cpp:2261
void setPreviousDecl(VarDecl *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2923
TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, SourceLocation StartL)
Definition: Decl.h:2896
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
Definition: Decl.h:750
const Expr * getInitExpr() const
Definition: Decl.h:2571
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2554
void setEmbeddedInDeclarator(bool isInDeclarator)
Definition: Decl.h:2978
redeclarable_base::redecl_range redecl_range
Definition: Decl.h:1771
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2770
CompoundStmt * getCompoundBody() const
Definition: Decl.h:3636
C Language Family Type Representation.
void setParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:3771
bool IsEvaluating
Whether this statement is being evaluated.
Definition: Decl.h:737
Expr * getCopyExpr() const
Definition: Decl.h:3593
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1487
static PragmaCommentDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned ArgSize)
Definition: Decl.cpp:4084
QualType getUnderlyingType() const
Definition: Decl.h:2727
Defines the clang::Module class, which describes a module in the source code.
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL)
Definition: Decl.h:654
redeclarable_base::redecl_iterator redecl_iterator
Definition: Decl.h:2927
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
void setRangeEnd(SourceLocation E)
Definition: Decl.h:1813
EnumDecl * getPreviousDecl()
Definition: Decl.h:3156
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition: Decl.h:2518
param_iterator param_end()
Definition: Decl.h:3656
StringRef P
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition: Decl.h:224
Parameter for Objective-C '_cmd' argument.
Definition: Decl.h:1392
const RecordDecl * getMostRecentDecl() const
Definition: Decl.h:3402
bool hasFlexibleArrayMember() const
Definition: Decl.h:3406
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
Definition: Decl.h:2132
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
Definition: Decl.h:3331
ImplicitParamKind
Defines the kind of the implicit parameter: is this an implicit parameter with pointer to 'this'...
Definition: Decl.h:1389
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:195
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
Definition: Type.h:1303
Represents an empty-declaration.
Definition: Decl.h:3938
void setCopyExpr(Expr *e)
Definition: Decl.h:3594
enumerator_iterator enumerator_end() const
Definition: Decl.h:3209
bool hasLinkage() const
Determine whether this declaration has linkage.
Definition: Decl.cpp:1656
friend TrailingObjects
Definition: Decl.h:3816
const EnumDecl * getMostRecentDecl() const
Definition: Decl.h:3167
Declaration of a variable template.
const Expr * getInit() const
Definition: Decl.h:1146
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:461
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: Decl.h:1491
Redeclarable< TagDecl > redeclarable_base
Definition: Decl.h:2909
A container of type source information.
Definition: Decl.h:62
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:272
StringLiteral * getAsmString()
Definition: Decl.h:3546
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3242
bool CheckingICE
Whether we are checking whether this statement is an integral constant expression.
Definition: Decl.h:745
enumerator_iterator enumerator_begin() const
Definition: Decl.h:3202
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Definition: Decl.h:3059
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:403
void setInitStyle(InitializationStyle Style)
Definition: Decl.h:1191
redeclarable_base::redecl_iterator redecl_iterator
Definition: Decl.h:2712
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
Definition: Decl.h:2489
InClassInitStyle getInClassInitStyle() const
getInClassInitStyle - Get the kind of (C++11) in-class initializer which this field has...
Definition: Decl.h:2473
Represents a #pragma comment line.
Definition: Decl.h:109
const VarDecl * getDefinition() const
Definition: Decl.h:1111
static CapturedDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:3810
bool hasLoadedFieldsFromExternalStorage() const
Definition: Decl.h:3432
VarDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: Decl.h:922
ExplicitVisibilityKind
Kinds of explicit visibility.
Definition: Decl.h:351
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
Definition: Decl.cpp:2151
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:758
bool isFileVarDecl() const
isFileVarDecl - Returns true for file scoped variable declaration.
Definition: Decl.h:1120
bool WasEvaluated
Whether this statement was already evaluated.
Definition: Decl.h:734
bool capturesCXXThis() const
Definition: Decl.h:3687
RecordDecl * getPreviousDecl()
Definition: Decl.h:3391
unsigned getBlockManglingNumber() const
Definition: Decl.h:3699
bool isInlineSpecified() const
Definition: Decl.h:1284
const FunctionDecl * getDefinition() const
Definition: Decl.h:1850
TLSKind getTLSKind() const
Definition: Decl.cpp:1876
static bool classofKind(Kind K)
Definition: Decl.h:2785
bool hasCaptures() const
hasCaptures - True if this block (or its nested blocks) captures anything of local storage from its e...
Definition: Decl.h:3674
The "union" keyword.
Definition: Type.h:4494
size_t numTrailingObjects(OverloadToken< ImplicitParamDecl >)
Definition: Decl.h:3731
Declaration context for names declared as extern "C" in C++.
Definition: Decl.h:191
TagTypeKind TagKind
Definition: Decl.h:2820
The "__interface" keyword.
Definition: Type.h:4492
Parameter for Objective-C 'self' argument.
Definition: Decl.h:1391
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:377
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
Definition: Decl.h:1005
NamespaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this namespace.
Definition: Decl.h:547
const TypedefNameDecl * getCanonicalDecl() const
Definition: Decl.h:2741
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:573
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:50
static StringRef getTagTypeKindName(TagTypeKind Kind)
Definition: Type.h:4560
static bool classof(const Decl *D)
Definition: Decl.h:2635
Visibility getVisibility() const
Determines the visibility of this entity.
Definition: Decl.h:343
NamespaceDecl * getAnonymousNamespace() const
Definition: Decl.h:92
Not a TLS variable.
Definition: Decl.h:775
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
decl_iterator decls_end() const
Definition: DeclBase.h:1539
static DeclContext * castToDeclContext(const ExportDecl *D)
Definition: Decl.h:3929
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1434
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:25
llvm::PointerUnion< Stmt *, EvaluatedStmt * > InitType
Definition: Decl.h:788
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:697
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:659
MutableArrayRef< ParmVarDecl * > parameters()
Definition: Decl.h:3647
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Definition: Decl.cpp:2181
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
Definition: Diagnostic.h:1067
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
Definition: Decl.h:334
Types, declared with 'struct foo', typedefs, etc.
Definition: DeclBase.h:125
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:813
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3354
Visibility getVisibility() const
Definition: Visibility.h:83
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
Definition: Decl.h:2230
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1549
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:80
FunctionDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain...
Definition: Decl.h:1763
static bool classofKind(Kind K)
Definition: Decl.h:1379
One of these records is kept for each identifier that is lexed.
void setIntegerType(QualType T)
Set the underlying integer type.
Definition: Decl.h:3235
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3282
static bool classofKind(Kind K)
Definition: Decl.h:3501
Defines the Linkage enumeration and various utility functions.
static bool classof(const Decl *D)
Definition: Decl.h:2676
redeclarable_base::redecl_iterator redecl_iterator
Definition: Decl.h:494
Copy initialization.
Definition: Specifiers.h:227
void setCompleteDefinition(bool V)
Definition: Decl.h:3009
void setUninstantiatedDefaultArg(Expr *arg)
Definition: Decl.cpp:2510
RecordDecl * getParent()
Definition: Decl.h:2532
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
A C++ nested-name-specifier augmented with source location information.
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
Definition: Decl.h:741
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition: Decl.cpp:2373
static bool classof(const Decl *D)
Definition: Decl.h:456
bool isIdentifier() const
Predicate functions for querying what type of name this is.
QualType getReturnType() const
Definition: Decl.h:2106
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
void setBlockMissingReturnType(bool val)
Definition: Decl.h:3689
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:2960
friend class DeclContext
Definition: DeclBase.h:234
Parameter for C++ 'this' argument.
Definition: Decl.h:1393
void setLocStart(SourceLocation L)
Definition: Decl.h:443
StringRef getArg() const
Definition: Decl.h:134
bool isClass() const
Definition: Decl.h:3027
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition: Decl.h:511
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope.
Definition: Decl.cpp:1572
const EnumDecl * getCanonicalDecl() const
Definition: Decl.h:3152
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1898
static DeclContext * castToDeclContext(const FunctionDecl *D)
Definition: Decl.h:2352
redecl_iterator redecls_begin() const
Definition: Redeclarable.h:295
ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind)
Definition: Decl.h:1416
TagKind getTagKind() const
Definition: Decl.h:3019
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition: Decl.h:1318
void overrideType(QualType T)
Override the type stored in this TypeSourceInfo. Use with caution!
Definition: Decl.h:76
Linkage getFormalLinkage(Linkage L)
Definition: Linkage.h:91
This declaration is definitely a definition.
Definition: Decl.h:1078
static bool classofKind(Kind K)
Definition: Decl.h:3343
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:3637
void setNumPositiveBits(unsigned Num)
Definition: Decl.h:3255
llvm::iterator_range< param_iterator > param_range
Definition: Decl.h:3797
unsigned getNumCaptures() const
getNumCaptures - Returns the number of captured variables.
Definition: Decl.h:3678
TypedefNameDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition: Decl.h:2700
static NamespaceDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclCXX.cpp:2236
Describes a module or submodule.
Definition: Module.h:57
static PragmaCommentDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation CommentLoc, PragmaMSCommentKind CommentKind, StringRef Arg)
Definition: Decl.cpp:4071
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
Definition: Decl.h:2954
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:947
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
Definition: Decl.h:996
static bool classofKind(Kind K)
Definition: Decl.h:718
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
Definition: Decl.cpp:1548
bool isLinkageValid() const
True if the computed linkage is valid.
Definition: Decl.cpp:1055
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:494
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
Definition: Decl.h:2740
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Definition: Decl.h:1919
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
Definition: Decl.cpp:2052
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:3767
static NamespaceDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:569
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
Definition: Decl.h:617
InitializationStyle
Initialization styles.
Definition: Decl.h:767
static bool classof(const Decl *D)
Definition: Decl.h:2585
VarDecl * getNextRedeclaration() const
Definition: Redeclarable.h:187
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3067
TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation StartL=SourceLocation())
Definition: Decl.h:2654
QualType getOriginalType() const
Definition: Decl.cpp:2444
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:516
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
Definition: Decl.cpp:4118
DeclLink RedeclLink
Points to the next redeclaration in the chain.
Definition: Redeclarable.h:184
SourceLocation getRBraceLoc() const
Definition: Decl.h:559
A convenient class for passing around template argument information.
Definition: TemplateBase.h:524
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
Definition: Decl.h:1043
uint32_t Offset
Definition: CacheTokens.cpp:43
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Definition: Decl.h:1425
virtual void printName(raw_ostream &os) const
Definition: Decl.cpp:1447
bool isFunctionOrMethodVarDecl() const
isFunctionOrMethodVarDecl - Similar to isLocalVarDecl, but excludes variables declared in blocks...
Definition: Decl.h:1049
Parameter for C++ virtual table pointers.
Definition: Decl.h:1394
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Definition: Decl.h:1914
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Definition: Decl.cpp:1954
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:32
field_range fields() const
Definition: Decl.h:3483
VarDecl * getVarDecl() const
Definition: Decl.h:2626
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1797
TypeDecl - Represents a declaration of a type.
Definition: Decl.h:2642
void setHasObjectMember(bool val)
Definition: Decl.h:3427
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
Definition: Decl.cpp:2254
A set of unresolved declarations.
Definition: UnresolvedSet.h:56
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition: Decl.h:2513
void setHasImplicitReturnZero(bool IRZ)
Definition: Decl.h:1926
void setExceptionVariable(bool EV)
Definition: Decl.h:1235
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
Definition: Decl.h:2166
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Definition: Decl.h:252
LabelStmt * getStmt() const
Definition: Decl.h:439
chain_iterator chain_begin() const
Definition: Decl.h:2616
static bool classof(const Decl *D)
Definition: Decl.h:97
FunctionDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: Decl.h:1766
void setTrivial(bool IT)
Definition: Decl.h:1910
static BlockDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:3719
TagDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain...
Definition: Decl.h:2913
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
Definition: Decl.cpp:4151
static bool classof(const Decl *D)
Definition: Decl.h:3805
TypedefNameDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain...
Definition: Decl.h:2703
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:796
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
void setNumNegativeBits(unsigned Num)
Definition: Decl.h:3272
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
Definition: Decl.h:987
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
Definition: Decl.cpp:1858
static bool classofKind(Kind K)
Definition: Decl.h:1430
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition: Decl.h:1214
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Definition: Decl.cpp:1737
static bool classofKind(Kind K)
Definition: Decl.h:138
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3726
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:2452
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1306
const EnumConstantDecl * getCanonicalDecl() const
Definition: Decl.h:2582
detail::InMemoryDirectory::const_iterator I
size_t param_size() const
Definition: Decl.h:3659
void setInitVal(const llvm::APSInt &V)
Definition: Decl.h:2576
Ordinary names.
Definition: DeclBase.h:139
QualType getType() const
Definition: Decl.h:589
void setInitExpr(Expr *E)
Definition: Decl.h:2575
void setStmt(LabelStmt *T)
Definition: Decl.h:440
void setLocStart(SourceLocation L)
Definition: Decl.h:2667
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
Definition: Decl.h:1780
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Decl.h:3915
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
Definition: Decl.h:2440
VarDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain...
Definition: Decl.h:919
param_iterator param_begin()
Definition: Decl.h:2077
void setHasInheritedPrototype(bool P=true)
Definition: Decl.h:1941
field_iterator field_end() const
Definition: Decl.h:3486
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Definition: Decl.h:1932
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
Definition: Decl.cpp:2311
static bool classof(const Decl *D)
Definition: Decl.h:3342
static bool classof(const Decl *D)
Definition: Decl.h:2784
void removeInClassInitializer()
removeInClassInitializer - Remove the C++11 in-class initializer from this member.
Definition: Decl.h:2506
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
Definition: Decl.h:521
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion: ...
Definition: Decl.h:1508
unsigned getNumParams() const
Definition: Decl.h:3765
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Definition: Decl.cpp:4161
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition: Decl.h:1902
bool isUnion() const
Definition: Decl.h:3028
ArrayRef< ParmVarDecl * >::const_iterator param_const_iterator
Definition: Decl.h:2075
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:285
void setLazyBody(uint64_t Offset)
Definition: Decl.h:1887
bool isExternalFormalLinkage(Linkage L)
Definition: Linkage.h:104
RecordDecl * getMostRecentDecl()
Definition: Decl.h:3399
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:97
const FormatStyle & Style
Definition: Format.cpp:1463
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2790
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:953
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:575
void setHasLoadedFieldsFromExternalStorage(bool val)
Definition: Decl.h:3435
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
Definition: Decl.h:610
bool isConversionFromLambda() const
Definition: Decl.h:3691
static bool classof(const Decl *D)
Definition: Decl.h:1378
static bool classofKind(Kind K)
Definition: Decl.h:565
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2666
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Definition: Decl.cpp:2529
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:636
FieldDecl * getAnonField() const
Definition: Decl.h:2621
unsigned getChainingSize() const
Definition: Decl.h:2619
SourceLocation getTypeSpecStartLoc() const
Definition: Decl.cpp:1701
ASTContext * Context
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:2940
bool usesSEHTry() const
Indicates the function uses __try.
Definition: Decl.h:1957
bool isEnum() const
Definition: Decl.h:3029
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
Definition: Decl.cpp:2392
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition: Decl.cpp:1674
Redeclarable< TypedefNameDecl > redeclarable_base
Definition: Decl.h:2699
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2136
static bool classof(const Decl *D)
Definition: Decl.h:3549
void setInClassInitializer(Expr *Init)
setInClassInitializer - Set the C++11 in-class initializer for this member.
Definition: Decl.h:2497
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition: Decl.h:305
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Definition: Decl.h:2407
static bool classof(const Decl *D)
Definition: Decl.h:2543
Stmt ** getInitAddress()
Retrieve the address of the initializer expression.
Definition: Decl.cpp:2119
TypedefNameDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: Decl.h:2706
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:1979
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2383
const Type * getTypeForDecl() const
Definition: Decl.h:2663
const Type * getTypePtrOrNull() const
Definition: Type.h:5493
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3557
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
Expr - This represents one expression.
Definition: Expr.h:105
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
Definition: Decl.h:1209
TypedefNameDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition: Decl.h:2693
StringRef getName() const
Return the actual identifier string.
const EnumDecl * getPreviousDecl() const
Definition: Decl.h:3160
void setBitWidth(Expr *Width)
setBitWidth - Set the bit-field width for this member.
Definition: Decl.h:2457
bool isModed() const
Definition: Decl.h:2720
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition: Decl.h:2049
static bool classofKind(Kind K)
Definition: Decl.h:2636
std::string Label
static bool classof(const Decl *D)
Definition: Decl.h:3927
bool isDeletedAsWritten() const
Definition: Decl.h:1980
VarDecl * getVariable() const
The variable being captured.
Definition: Decl.h:3582
const NamedDecl * getMostRecentDecl() const
Definition: Decl.h:394
bool isStruct() const
Definition: Decl.h:3025
const NamedDecl * getUnderlyingDecl() const
Definition: Decl.h:387
Expr * getBitWidth() const
Definition: Decl.h:2448
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2613
void setRBraceLoc(SourceLocation L)
Definition: Decl.h:561
void setInit(Expr *I)
Definition: Decl.cpp:2142
void setContextParam(unsigned i, ImplicitParamDecl *P)
Definition: Decl.h:3789
capture_const_iterator capture_begin() const
Definition: Decl.h:3684
Defines an enumeration for C++ overloaded operators.
Kind getKind() const
Definition: DeclBase.h:410
bool isGnuLocal() const
Definition: Decl.h:442
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2088
static DeclLink PreviousDeclLink(VarDecl *D)
Definition: Redeclarable.h:165
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:216
DeclContext * getDeclContext()
Definition: DeclBase.h:416
Redeclarable< VarDecl > redeclarable_base
Definition: Decl.h:915
static bool classofKind(Kind K)
Definition: Decl.h:2760
This declaration is a tentative definition.
Definition: Decl.h:1077
unsigned getContextParamPosition() const
Definition: Decl.h:3794
static bool classof(const Decl *D)
Definition: Decl.h:717
void setCompleteDefinitionRequired(bool V=true)
Definition: Decl.h:3011
bool isMSAsmLabel() const
Definition: Decl.h:449
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec...
Definition: Decl.cpp:1958
EnumDecl * getMostRecentDecl()
Definition: Decl.h:3164
bool isTransparentTag() const
Determines if this typedef shares a name and spelling location with its underlying tag type...
Definition: Decl.h:2752
const FieldDecl * getCanonicalDecl() const
Definition: Decl.h:2540
void setLateTemplateParsed(bool ILT=true)
Definition: Decl.h:1903
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
Definition: Decl.cpp:2490
void setLocStart(SourceLocation L)
Definition: Decl.h:560
static DeclContext * castToDeclContext(const CapturedDecl *D)
Definition: Decl.h:3807
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition: Decl.h:2156
bool isObjCMethodParameter() const
Definition: Decl.h:1477
MutableArrayRef< ParmVarDecl * > parameters()
Definition: Decl.h:2069
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:604
void setConstexpr(bool IC)
Definition: Decl.h:1302
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3277
StorageClass
Storage classes.
Definition: Specifiers.h:202
SourceLocation getRParenLoc() const
Definition: Decl.h:3539
PragmaMSCommentKind
Definition: PragmaKinds.h:15
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition: Decl.h:1232
Direct list-initialization (C++11)
Definition: Decl.h:770
bool isFunctionOrMethod() const
Definition: DeclBase.h:1343
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:225
Declaration of an alias template.
bool isExternallyVisible(Linkage L)
Definition: Linkage.h:87
SourceLocation getExportLoc() const
Definition: Decl.h:3911
bool isExternallyVisible() const
Definition: Decl.h:338
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
Definition: Decl.h:2735
param_const_iterator param_end() const
Definition: Decl.h:2080
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Definition: Decl.h:2096
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3644
specific_decl_iterator< FieldDecl > field_iterator
Definition: Decl.h:3480
static bool classof(const Decl *D)
Definition: Decl.h:1583
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
TagDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: Decl.h:2916
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition: Decl.h:2807
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1076
TagDecl * getDefinition() const
getDefinition - Returns the TagDecl that actually defines this struct/union/class/enum.
Definition: Decl.cpp:3698
static DeclContext * castToDeclContext(const NamespaceDecl *D)
Definition: Decl.h:566
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Definition: Decl.h:329
void setStorageClass(StorageClass SC)
Definition: Decl.cpp:1871
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
Definition: Decl.cpp:1063
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:148
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Definition: Decl.h:3046
const VarDecl * getCanonicalDecl() const
Definition: Decl.h:1071
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:3473
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition: Decl.h:1940
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
Definition: Decl.cpp:2267
bool IsEnumDeclComplete(EnumDecl *ED)
Check if the given decl is complete.
Definition: Decl.h:4006
void setBlockMangling(unsigned Number, Decl *Ctx)
Definition: Decl.h:3706
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:166
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:661
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:264
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3050
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:1966
static bool classofKind(Kind K)
Definition: Decl.h:3806
static bool classof(const Decl *D)
Definition: Decl.h:2759
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
Definition: Decl.h:1136
Optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
Definition: Decl.cpp:1159
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition: Decl.h:1944
VarDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:209
bool param_empty() const
Definition: Decl.h:3654
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:1893
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:3662
bool instantiationIsPending() const
Whether the instantiation of this function is pending.
Definition: Decl.h:1953
param_iterator param_begin()
Definition: Decl.h:3655
bool isEmbeddedInDeclarator() const
Definition: Decl.h:2975
void setIsVariadic(bool value)
Definition: Decl.h:3634
Thread storage duration.
Definition: Specifiers.h:275
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
Definition: Decl.h:3619
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
Definition: Decl.cpp:4110
void setTypeForDecl(const Type *TD)
Definition: Decl.h:2664
static bool classof(const Decl *D)
Definition: Decl.h:564
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:3894
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:554
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Definition: Decl.h:1882
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
Definition: Decl.h:603
static bool classofKind(Kind K)
Definition: Decl.h:2812
StringRef getValue() const
Definition: Decl.h:167
ArrayRef< Capture >::const_iterator capture_const_iterator
Definition: Decl.h:3680
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:222
static bool classofKind(Kind K)
Definition: Decl.h:3086
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:289
static bool classof(const Decl *D)
Definition: Decl.h:3500
#define false
Definition: stdbool.h:33
The "struct" keyword.
Definition: Type.h:4490
Kind
static ExternCContextDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:206
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:2458
NamespaceDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:197
void setIsConversionFromLambda(bool val)
Definition: Decl.h:3692
redeclarable_base::redecl_range redecl_range
Definition: Decl.h:927
void setKNRPromoted(bool promoted)
Definition: Decl.h:1511
bool isInterface() const
Definition: Decl.h:3026
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
Definition: Decl.cpp:1753
Encodes a location in the source.
enumerator_range enumerators() const
Definition: Decl.h:3198
static DeclContext * castToDeclContext(const TranslationUnitDecl *D)
Definition: Decl.h:99
static bool classof(const Decl *D)
Definition: Decl.h:201
static bool classofKind(Kind K)
Definition: Decl.h:3885
void setBraceRange(SourceRange R)
Definition: Decl.h:2936
ParmVarDecl * getParamDecl(unsigned i)
Definition: Decl.h:2092
void setAnonymousNamespace(NamespaceDecl *D)
Definition: Decl.h:542
static bool classofKind(Kind K)
Definition: Decl.h:2586
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:558
SourceRange getBraceRange() const
Definition: Decl.h:2935
void setFreeStanding(bool isFreeStanding=true)
Definition: Decl.h:2983
const std::string ID
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2816
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
Definition: Linkage.h:66
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:346
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
Definition: Decl.h:1034
capture_const_iterator capture_end() const
Definition: Decl.h:3685
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:414
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:3664
redeclarable_base::redecl_range redecl_range
Definition: Decl.h:2711
void setDefaulted(bool D=true)
Definition: Decl.h:1915
void setHasFlexibleArrayMember(bool V)
Definition: Decl.h:3407
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.h:3149
bool blockMissingReturnType() const
Definition: Decl.h:3688
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
C-style initialization with assignment.
Definition: Decl.h:768
redecl_iterator redecls_end() const
Definition: Redeclarable.h:296
void setInstantiationOfMemberEnum(EnumDecl *ED, TemplateSpecializationKind TSK)
Specify that this enumeration is an instantiation of the member enumeration ED.
Definition: Decl.h:3337
param_iterator param_begin() const
Retrieve an iterator pointing to the first parameter decl.
Definition: Decl.h:3800
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2066
static bool classof(const Decl *D)
Definition: Decl.h:400
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
Definition: Decl.h:1224
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:948
ASTContext & getASTContext() const
Definition: Decl.h:90
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:3873
IndirectFieldDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.h:2631
redeclarable_base::redecl_range redecl_range
Definition: Decl.h:493
void setDeclName(DeclarationName N)
Set the name of this declaration.
Definition: Decl.h:261
Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
Definition: Decl.h:3576
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, bool isConstexprSpecified)
Definition: Decl.h:1740
ParmVarDecl * getParamDecl(unsigned i)
Definition: Decl.h:3666
bool hasVolatileMember() const
Definition: Decl.h:3429
void setTagKind(TagKind TK)
Definition: Decl.h:3023
This declaration is only a declaration.
Definition: Decl.h:1076
Direct list-initialization.
Definition: Specifiers.h:228
void removeBitWidth()
removeBitWidth - Remove the bit-field width from this member.
Definition: Decl.h:2466
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
Definition: Decl.cpp:1082
static ExportDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:3932
ThreadStorageClassSpecifier getTSCSpec() const
Definition: Decl.h:956
llvm::iterator_range< specific_decl_iterator< EnumConstantDecl > > enumerator_range
Definition: Decl.h:3196
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1898
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Definition: Decl.h:2990
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
Definition: Decl.cpp:2356
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2140
bool hasObjectMember() const
Definition: Decl.h:3426
bool hasCachedLinkage() const
Definition: DeclBase.h:390
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:1863
static DeclContext * castToDeclContext(const BlockDecl *D)
Definition: Decl.h:3716
void setExplicitlyDefaulted(bool ED=true)
Definition: Decl.h:1920
void setHasInheritedDefaultArg(bool I=true)
Definition: Decl.h:1566
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:70
static bool classofKind(Kind K)
Definition: Decl.h:598
void printQualifiedName(raw_ostream &OS) const
printQualifiedName - Returns human-readable qualified name for declaration, like A::B::i, for i being member of namespace A::B.
Definition: Decl.cpp:1458
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3829
void setVirtualAsWritten(bool V)
Definition: Decl.h:1894
C++11 thread_local.
Definition: Specifiers.h:195
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
static const char * getStorageClassSpecifierString(StorageClass SC)
getStorageClassSpecifierString - Return the string used to specify the storage class SC...
Definition: Decl.cpp:1828
Decl * getBlockManglingContextDecl() const
Definition: Decl.h:3702
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:1496
const RecordDecl * getPreviousDecl() const
Definition: Decl.h:3395
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Definition: Decl.cpp:2401
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition: Decl.h:1308
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2682
const VarDecl * getDefinition(ASTContext &C) const
Definition: Decl.h:1105
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Definition: Decl.h:3421
TLS with a dynamic initializer.
Definition: Decl.h:777
void setAnonymousNamespace(NamespaceDecl *D)
Definition: Decl.h:93
TagTypeKind
The kind of a tag type.
Definition: Type.h:4488
unsigned getNumParams() const
Definition: Decl.h:3661
static bool classofKind(Kind K)
Definition: Decl.h:2349
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2435
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Definition: Decl.h:2808
void setBody(CompoundStmt *B)
Definition: Decl.h:3638
void setImplicitlyInline()
Flag that this function is implicitly inline.
Definition: Decl.h:2149
MutableArrayRef< ImplicitParamDecl * > parameters()
Definition: Decl.h:3780
void setHasVolatileMember(bool val)
Definition: Decl.h:3430
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
StringRef Name
Definition: USRFinder.cpp:123
FunctionDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition: Decl.h:1760
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
Definition: Decl.h:1545
redeclarable_base::redecl_range redecl_range
Definition: Decl.h:2926
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
Definition: Decl.cpp:4094
VarDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition: Decl.h:916
QualType getPromotionType() const
getPromotionType - Return the integer type that enumerators should promote to.
Definition: Decl.h:3218
PragmaMSCommentKind getCommentKind() const
Definition: Decl.h:132
unsigned getNumTemplateParameterLists() const
Definition: Decl.h:3074
InitType Init
The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
Definition: Decl.h:792
ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.h:1440
Redeclarable< FunctionDecl > redeclarable_base
Definition: Decl.h:1759
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:328
TagDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition: Decl.h:2910
void setARCPseudoStrong(bool ps)
Definition: Decl.h:1275
bool param_empty() const
Definition: Decl.h:2076
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2594
bool isFreeStanding() const
Definition: Decl.h:2982
static bool classof(const Decl *D)
Definition: Decl.h:137
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3923
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2573
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2241
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition: DeclBase.h:110
bool hasWrittenPrototype() const
Definition: Decl.h:1936
TLSKind
Kinds of thread-local storage.
Definition: Decl.h:774
void setWillHaveBody(bool V=true)
Definition: Decl.h:2054
DeclarationName - The name of a declaration.
chain_iterator chain_end() const
Definition: Decl.h:2617
Expr * getDefaultArg()
Definition: Decl.cpp:2473
void setInstantiationIsPending(bool IC)
Definition: Decl.h:1954
void setInstantiationOfMemberFunction(FunctionDecl *FD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member function FD.
Definition: Decl.h:2207
specific_decl_iterator< EnumConstantDecl > enumerator_iterator
Definition: Decl.h:3194
ParmVarDeclBitfields ParmVarDeclBits
Definition: Decl.h:907
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:1874
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:683
size_t param_size() const
Definition: Decl.h:2081
EnumDecl - Represents an enum.
Definition: Decl.h:3102
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1481
detail::InMemoryDirectory::const_iterator E
void setInlineSpecified()
Definition: Decl.h:1288
bool hasCopyExpr() const
Definition: Decl.h:3592
static bool classof(const Decl *D)
Definition: Decl.h:2348
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:142
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Definition: DeclBase.h:120
void setPreviousDeclInSameBlockScope(bool Same)
Definition: Decl.h:1323
bool field_empty() const
Definition: Decl.h:3492
DefinitionKind hasDefinition() const
Definition: Decl.h:1092
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4137
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Definition: DeclBase.h:1557
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
Definition: Decl.cpp:4125
param_iterator param_end()
Definition: Decl.h:2078
void setInitCapture(bool IC)
Definition: Decl.h:1311
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition: Decl.h:2966
StringRef getName() const
Definition: Decl.h:166
bool hasInheritedDefaultArg() const
Definition: Decl.h:1562
void setImplicitlyInline()
Definition: Decl.h:1293
redeclarable_base::redecl_iterator redecl_iterator
Definition: Decl.h:928
Not an overloaded operator.
Definition: OperatorKinds.h:23
ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType Type, ImplicitParamKind ParamKind)
Definition: Decl.h:1407
static FunctionDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:2355
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:310
param_const_iterator param_begin() const
Definition: Decl.h:3657
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3269
static const TypeInfo & getInfo(unsigned id)
Definition: Types.cpp:34
void setUnparsedDefaultArg()
setUnparsedDefaultArg - Specify that this parameter has an unparsed default argument.
Definition: Decl.h:1558
NonParmVarDeclBitfields NonParmVarDeclBits
Definition: Decl.h:908
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2515
SourceLocation getCaretLocation() const
Definition: Decl.h:3631
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:6042
Decl::Kind getDeclKind() const
Definition: DeclBase.h:1288
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: Decl.cpp:4173
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Definition: Decl.cpp:1707
friend TrailingObjects
Definition: OpenMPClause.h:82
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3226
void setTypeSourceInfo(TypeSourceInfo *TI)
Definition: Decl.h:666
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
Definition: Decl.cpp:2424
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition: Decl.h:3652
void setUsesSEHTry(bool UST)
Definition: Decl.h:1958
static bool classof(const Decl *D)
Definition: Decl.h:2811
bool isComplete() const
Returns true if this can be considered a complete type.
Definition: Decl.h:3293
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
Definition: Decl.cpp:1950
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1634
SourceLocation getAsmLoc() const
Definition: Decl.h:3538
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1250
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition: Decl.h:1909
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2255
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1205
void setCXXForRangeDecl(bool FRD)
Definition: Decl.h:1263
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
Definition: Decl.h:3785
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:445
static bool classofKind(Kind K)
Definition: Decl.h:2544
The "class" keyword.
Definition: Type.h:4496
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition: Decl.h:1065
redeclarable_base::redecl_iterator redecl_iterator
Definition: Decl.h:1772
ArrayRef< ParmVarDecl * >::const_iterator param_const_iterator
Definition: Decl.h:3653
static bool classofKind(Kind K)
Definition: Decl.h:3715
void setInnerLocStart(SourceLocation L)
Definition: Decl.h:676
void setObjCMethodScopeInfo(unsigned parameterIndex)
Definition: Decl.h:1462
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1260
std::string getQualifiedNameAsString() const
Definition: Decl.cpp:1451
virtual bool isDefined() const
Definition: Decl.h:1838
void setSignatureAsWritten(TypeSourceInfo *Sig)
Definition: Decl.h:3640
void setPromotionType(QualType T)
Set the promotion type.
Definition: Decl.h:3221
void setAsmString(StringLiteral *Asm)
Definition: Decl.h:3547
void setRParenLoc(SourceLocation L)
Definition: Decl.h:3540
A template argument list.
Definition: DeclTemplate.h:195
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Definition: Decl.h:2053
ImplicitParamDecl *const * param_iterator
Definition: Decl.h:3796
void setRBraceLoc(SourceLocation L)
Definition: Decl.h:3913
param_iterator param_end() const
Retrieve an iterator one past the last parameter decl.
Definition: Decl.h:3802
NestedNameSpecifierLoc QualifierLoc
Definition: Decl.h:604
static bool classofKind(Kind K)
Definition: Decl.h:1584
Call-style initialization (C++98)
Definition: Decl.h:769
static DeclContext * castToDeclContext(const TagDecl *D)
Definition: Decl.h:3088
static bool classofKind(Kind K)
Definition: Decl.h:3928
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
Definition: Decl.h:585
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:189
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition: Decl.h:1272
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:5569
void setDefaultArg(Expr *defarg)
Definition: Decl.cpp:2485
void setTSCSpec(ThreadStorageClassSpecifier TSC)
Definition: Decl.h:952
TypeSourceInfo * getSignatureAsWritten() const
Definition: Decl.h:3641
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:190
void setDescribedVarTemplate(VarTemplateDecl *Template)
Definition: Decl.cpp:2388
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
Definition: Decl.cpp:2126
static TranslationUnitDecl * Create(ASTContext &C)
Definition: Decl.cpp:4065
static bool classofKind(Kind K)
Definition: Decl.h:2677
void setConstexpr(bool IC)
Definition: Decl.h:1945
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:595
bool isInline() const
Whether this variable is (C++1z) inline.
Definition: Decl.h:1281
void setMSAsmLabel(StringRef Name)
Definition: Decl.cpp:4142
Decl(Kind DK, DeclContext *DC, SourceLocation L)
Definition: DeclBase.h:358
VarDecl * getDefinition()
Definition: Decl.h:1108
const FunctionDecl * getCanonicalDecl() const
Definition: Decl.h:2059
The "enum" keyword.
Definition: Type.h:4498
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:2668
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1299
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
Definition: Decl.cpp:2246
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:44
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition: Decl.h:2074
const Expr * getUninstantiatedDefaultArg() const
Definition: Decl.h:1527
TemplateParameterList * getTemplateParameterList(unsigned i) const
Definition: Decl.h:3077
static bool classof(const Decl *D)
Definition: Decl.h:170
static bool classofKind(Kind K)
Definition: Decl.h:98
const VarDecl * getActingDefinition() const
Definition: Decl.h:1099
const IndirectFieldDecl * getCanonicalDecl() const
Definition: Decl.h:2632
bool isNested() const
Whether this is a nested capture, i.e.
Definition: Decl.h:3590
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1506
TLS with a known-constant initializer.
Definition: Decl.h:776
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:84
const Expr * getDefaultArg() const
Definition: Decl.h:1516
static TagDecl * castFromDeclContext(const DeclContext *DC)
Definition: Decl.h:3091
VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
Definition: Decl.cpp:1841
bool isRecord() const
Definition: DeclBase.h:1368
VarDeclBitfields VarDeclBits
Definition: Decl.h:906
NamespaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:219
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:80
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Definition: Decl.h:689
static bool classofKind(Kind K)
Definition: Decl.h:171
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:538
bool isInExternCXXContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec...
Definition: Decl.cpp:1962
static bool classof(const Decl *D)
Definition: Decl.h:3948
NamedDecl * getMostRecentDecl()
Definition: Decl.h:391
DefinitionKind isThisDeclarationADefinition() const
Definition: Decl.h:1085
EnumConstantDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
Definition: Decl.h:2558
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:675
bool isResolvedMSAsmLabel() const
Definition: Decl.h:450
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
Definition: Decl.h:1495
void setMSAsmLabelResolved()
Definition: Decl.h:453
TemplateParameterList * getTemplateParameterList(unsigned index) const
Definition: Decl.h:707
#define true
Definition: stdbool.h:32
unsigned AllBits
Definition: Decl.h:905
StringRef getKindName() const
Definition: Decl.h:3015
void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, const TemplateArgumentList *TemplateArgs, void *InsertPos, TemplateSpecializationKind TSK=TSK_ImplicitInstantiation, const TemplateArgumentListInfo *TemplateArgsAsWritten=nullptr, SourceLocation PointOfInstantiation=SourceLocation())
Specify that this function declaration is actually a function template specialization.
Definition: Decl.h:2300
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
Definition: DeclBase.h:407
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
Definition: Decl.h:3238
SourceLocation getRBraceLoc() const
Definition: Decl.h:3912
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:1806
void setTypeSourceInfo(TypeSourceInfo *newType)
Definition: Decl.h:2732
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2648
EnumDecl * getDefinition() const
Definition: Decl.h:3171
Automatic storage duration (most local variables).
Definition: Specifiers.h:274
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition: Decl.h:1925
const NamespaceDecl * getCanonicalDecl() const
Definition: Decl.h:550
APValue Evaluated
Definition: Decl.h:753
Represents a #pragma detect_mismatch line.
Definition: Decl.h:143
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2722
static bool classofKind(Kind K)
Definition: Decl.h:457
void setNRVOVariable(bool NRVO)
Definition: Decl.h:1253
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1008
static bool classof(const Decl *D)
Definition: Decl.h:1429
void setType(QualType newType)
Definition: Decl.h:590
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Definition: DeclBase.h:954
void setDeletedAsWritten(bool D=true)
Definition: Decl.h:1981
No in-class initializer.
Definition: Specifiers.h:226
void setInlineSpecified(bool I)
Set whether the "inline" keyword was specified for this function.
Definition: Decl.h:2143
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:586
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
Definition: Decl.h:2971
Declaration of a template function.
Definition: DeclTemplate.h:939
ArrayRef< ImplicitParamDecl * > parameters() const
Definition: Decl.h:3777
Attr - This represents one attribute.
Definition: Attr.h:43
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
Definition: Decl.h:963
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
Definition: Decl.h:2528
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
setTemplateParameterListsInfo - Sets info about "outer" template parameter lists. ...
Definition: Decl.cpp:1808
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2431
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
Definition: Decl.h:2481
unsigned getNumTemplateParameterLists() const
Definition: Decl.h:704
Structure used to store a statement, the constant value to which it was evaluated (if any)...
Definition: Decl.h:729
const StringLiteral * getAsmString() const
Definition: Decl.h:3545
bool hasInit() const
Definition: Decl.cpp:2101
TemplatedKind
The kind of templated function a FunctionDecl can be.
Definition: Decl.h:1622