clang  17.0.0git
DeclBase.h
Go to the documentation of this file.
1 //===- DeclBase.h - Base Classes for representing declarations --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the Decl and DeclContext interfaces.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_AST_DECLBASE_H
14 #define LLVM_CLANG_AST_DECLBASE_H
15 
17 #include "clang/AST/AttrIterator.h"
20 #include "clang/Basic/LLVM.h"
22 #include "clang/Basic/Specifiers.h"
23 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/ADT/PointerIntPair.h"
25 #include "llvm/ADT/PointerUnion.h"
26 #include "llvm/ADT/iterator.h"
27 #include "llvm/ADT/iterator_range.h"
28 #include "llvm/Support/Casting.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/PrettyStackTrace.h"
31 #include "llvm/Support/VersionTuple.h"
32 #include <algorithm>
33 #include <cassert>
34 #include <cstddef>
35 #include <iterator>
36 #include <string>
37 #include <type_traits>
38 #include <utility>
39 
40 namespace clang {
41 
42 class ASTContext;
43 class ASTMutationListener;
44 class Attr;
45 class BlockDecl;
46 class DeclContext;
47 class ExternalSourceSymbolAttr;
48 class FunctionDecl;
49 class FunctionType;
50 class IdentifierInfo;
51 enum Linkage : unsigned char;
52 class LinkageSpecDecl;
53 class Module;
54 class NamedDecl;
55 class ObjCContainerDecl;
56 class ObjCMethodDecl;
57 struct PrintingPolicy;
58 class RecordDecl;
59 class SourceManager;
60 class Stmt;
61 class StoredDeclsMap;
62 class TemplateDecl;
63 class TemplateParameterList;
64 class TranslationUnitDecl;
65 class UsingDirectiveDecl;
66 
67 /// Captures the result of checking the availability of a
68 /// declaration.
74 };
75 
76 /// Decl - This represents one declaration (or definition), e.g. a variable,
77 /// typedef, function, struct, etc.
78 ///
79 /// Note: There are objects tacked on before the *beginning* of Decl
80 /// (and its subclasses) in its Decl::operator new(). Proper alignment
81 /// of all subclasses (not requiring more than the alignment of Decl) is
82 /// asserted in DeclBase.cpp.
83 class alignas(8) Decl {
84 public:
85  /// Lists the kind of concrete classes of Decl.
86  enum Kind {
87 #define DECL(DERIVED, BASE) DERIVED,
88 #define ABSTRACT_DECL(DECL)
89 #define DECL_RANGE(BASE, START, END) \
90  first##BASE = START, last##BASE = END,
91 #define LAST_DECL_RANGE(BASE, START, END) \
92  first##BASE = START, last##BASE = END
93 #include "clang/AST/DeclNodes.inc"
94  };
95 
96  /// A placeholder type used to construct an empty shell of a
97  /// decl-derived type that will be filled in later (e.g., by some
98  /// deserialization method).
99  struct EmptyShell {};
100 
101  /// IdentifierNamespace - The different namespaces in which
102  /// declarations may appear. According to C99 6.2.3, there are
103  /// four namespaces, labels, tags, members and ordinary
104  /// identifiers. C++ describes lookup completely differently:
105  /// certain lookups merely "ignore" certain kinds of declarations,
106  /// usually based on whether the declaration is of a type, etc.
107  ///
108  /// These are meant as bitmasks, so that searches in
109  /// C++ can look into the "tag" namespace during ordinary lookup.
110  ///
111  /// Decl currently provides 15 bits of IDNS bits.
113  /// Labels, declared with 'x:' and referenced with 'goto x'.
114  IDNS_Label = 0x0001,
115 
116  /// Tags, declared with 'struct foo;' and referenced with
117  /// 'struct foo'. All tags are also types. This is what
118  /// elaborated-type-specifiers look for in C.
119  /// This also contains names that conflict with tags in the
120  /// same scope but that are otherwise ordinary names (non-type
121  /// template parameters and indirect field declarations).
122  IDNS_Tag = 0x0002,
123 
124  /// Types, declared with 'struct foo', typedefs, etc.
125  /// This is what elaborated-type-specifiers look for in C++,
126  /// but note that it's ill-formed to find a non-tag.
127  IDNS_Type = 0x0004,
128 
129  /// Members, declared with object declarations within tag
130  /// definitions. In C, these can only be found by "qualified"
131  /// lookup in member expressions. In C++, they're found by
132  /// normal lookup.
133  IDNS_Member = 0x0008,
134 
135  /// Namespaces, declared with 'namespace foo {}'.
136  /// Lookup for nested-name-specifiers find these.
137  IDNS_Namespace = 0x0010,
138 
139  /// Ordinary names. In C, everything that's not a label, tag,
140  /// member, or function-local extern ends up here.
141  IDNS_Ordinary = 0x0020,
142 
143  /// Objective C \@protocol.
145 
146  /// This declaration is a friend function. A friend function
147  /// declaration is always in this namespace but may also be in
148  /// IDNS_Ordinary if it was previously declared.
150 
151  /// This declaration is a friend class. A friend class
152  /// declaration is always in this namespace but may also be in
153  /// IDNS_Tag|IDNS_Type if it was previously declared.
154  IDNS_TagFriend = 0x0100,
155 
156  /// This declaration is a using declaration. A using declaration
157  /// *introduces* a number of other declarations into the current
158  /// scope, and those declarations use the IDNS of their targets,
159  /// but the actual using declarations go in this namespace.
160  IDNS_Using = 0x0200,
161 
162  /// This declaration is a C++ operator declared in a non-class
163  /// context. All such operators are also in IDNS_Ordinary.
164  /// C++ lexical operator lookup looks for these.
166 
167  /// This declaration is a function-local extern declaration of a
168  /// variable or function. This may also be IDNS_Ordinary if it
169  /// has been declared outside any function. These act mostly like
170  /// invisible friend declarations, but are also visible to unqualified
171  /// lookup within the scope of the declaring function.
173 
174  /// This declaration is an OpenMP user defined reduction construction.
176 
177  /// This declaration is an OpenMP user defined mapper.
178  IDNS_OMPMapper = 0x2000,
179  };
180 
181  /// ObjCDeclQualifier - 'Qualifiers' written next to the return and
182  /// parameter types in method declarations. Other than remembering
183  /// them and mangling them into the method's signature string, these
184  /// are ignored by the compiler; they are consumed by certain
185  /// remote-messaging frameworks.
186  ///
187  /// in, inout, and out are mutually exclusive and apply only to
188  /// method parameters. bycopy and byref are mutually exclusive and
189  /// apply only to method parameters (?). oneway applies only to
190  /// results. All of these expect their corresponding parameter to
191  /// have a particular type. None of this is currently enforced by
192  /// clang.
193  ///
194  /// This should be kept in sync with ObjCDeclSpec::ObjCDeclQualifier.
197  OBJC_TQ_In = 0x1,
199  OBJC_TQ_Out = 0x4,
203 
204  /// The nullability qualifier is set when the nullability of the
205  /// result or parameter was expressed via a context-sensitive
206  /// keyword.
208  };
209 
210  /// The kind of ownership a declaration has, for visibility purposes.
211  /// This enumeration is designed such that higher values represent higher
212  /// levels of name hiding.
214  /// This declaration is not owned by a module.
215  Unowned,
216 
217  /// This declaration has an owning module, but is globally visible
218  /// (typically because its owning module is visible and we know that
219  /// modules cannot later become hidden in this compilation).
220  /// After serialization and deserialization, this will be converted
221  /// to VisibleWhenImported.
222  Visible,
223 
224  /// This declaration has an owning module, and is visible when that
225  /// module is imported.
227 
228  /// This declaration has an owning module, and is visible to lookups
229  /// that occurs within that module. And it is reachable in other module
230  /// when the owning module is transitively imported.
232 
233  /// This declaration has an owning module, but is only visible to
234  /// lookups that occur within that module.
235  /// The discarded declarations in global module fragment belongs
236  /// to this group too.
238  };
239 
240 protected:
241  /// The next declaration within the same lexical
242  /// DeclContext. These pointers form the linked list that is
243  /// traversed via DeclContext's decls_begin()/decls_end().
244  ///
245  /// The extra three bits are used for the ModuleOwnershipKind.
246  llvm::PointerIntPair<Decl *, 3, ModuleOwnershipKind> NextInContextAndBits;
247 
248 private:
249  friend class DeclContext;
250 
251  struct MultipleDC {
252  DeclContext *SemanticDC;
253  DeclContext *LexicalDC;
254  };
255 
256  /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
257  /// For declarations that don't contain C++ scope specifiers, it contains
258  /// the DeclContext where the Decl was declared.
259  /// For declarations with C++ scope specifiers, it contains a MultipleDC*
260  /// with the context where it semantically belongs (SemanticDC) and the
261  /// context where it was lexically declared (LexicalDC).
262  /// e.g.:
263  ///
264  /// namespace A {
265  /// void f(); // SemanticDC == LexicalDC == 'namespace A'
266  /// }
267  /// void A::f(); // SemanticDC == namespace 'A'
268  /// // LexicalDC == global namespace
269  llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
270 
271  bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); }
272  bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); }
273 
274  MultipleDC *getMultipleDC() const {
275  return DeclCtx.get<MultipleDC*>();
276  }
277 
278  DeclContext *getSemanticDC() const {
279  return DeclCtx.get<DeclContext*>();
280  }
281 
282  /// Loc - The location of this decl.
283  SourceLocation Loc;
284 
285  /// DeclKind - This indicates which class this is.
286  unsigned DeclKind : 7;
287 
288  /// InvalidDecl - This indicates a semantic error occurred.
289  unsigned InvalidDecl : 1;
290 
291  /// HasAttrs - This indicates whether the decl has attributes or not.
292  unsigned HasAttrs : 1;
293 
294  /// Implicit - Whether this declaration was implicitly generated by
295  /// the implementation rather than explicitly written by the user.
296  unsigned Implicit : 1;
297 
298  /// Whether this declaration was "used", meaning that a definition is
299  /// required.
300  unsigned Used : 1;
301 
302  /// Whether this declaration was "referenced".
303  /// The difference with 'Used' is whether the reference appears in a
304  /// evaluated context or not, e.g. functions used in uninstantiated templates
305  /// are regarded as "referenced" but not "used".
306  unsigned Referenced : 1;
307 
308  /// Whether this declaration is a top-level declaration (function,
309  /// global variable, etc.) that is lexically inside an objc container
310  /// definition.
311  unsigned TopLevelDeclInObjCContainer : 1;
312 
313  /// Whether statistic collection is enabled.
314  static bool StatisticsEnabled;
315 
316 protected:
317  friend class ASTDeclReader;
318  friend class ASTDeclWriter;
319  friend class ASTNodeImporter;
320  friend class ASTReader;
321  friend class CXXClassMemberWrapper;
322  friend class LinkageComputer;
323  friend class RecordDecl;
324  template<typename decl_type> friend class Redeclarable;
325 
326  /// Access - Used by C++ decls for the access specifier.
327  // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
328  unsigned Access : 2;
329 
330  /// Whether this declaration was loaded from an AST file.
331  unsigned FromASTFile : 1;
332 
333  /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
334  unsigned IdentifierNamespace : 14;
335 
336  /// If 0, we have not computed the linkage of this declaration.
337  /// Otherwise, it is the linkage + 1.
338  mutable unsigned CacheValidAndLinkage : 3;
339 
340  /// Allocate memory for a deserialized declaration.
341  ///
342  /// This routine must be used to allocate memory for any declaration that is
343  /// deserialized from a module file.
344  ///
345  /// \param Size The size of the allocated object.
346  /// \param Ctx The context in which we will allocate memory.
347  /// \param ID The global ID of the deserialized declaration.
348  /// \param Extra The amount of extra space to allocate after the object.
349  void *operator new(std::size_t Size, const ASTContext &Ctx, unsigned ID,
350  std::size_t Extra = 0);
351 
352  /// Allocate memory for a non-deserialized declaration.
353  void *operator new(std::size_t Size, const ASTContext &Ctx,
354  DeclContext *Parent, std::size_t Extra = 0);
355 
356 private:
357  bool AccessDeclContextCheck() const;
358 
359  /// Get the module ownership kind to use for a local lexical child of \p DC,
360  /// which may be either a local or (rarely) an imported declaration.
361  static ModuleOwnershipKind getModuleOwnershipKindForChildOf(DeclContext *DC) {
362  if (DC) {
363  auto *D = cast<Decl>(DC);
364  auto MOK = D->getModuleOwnershipKind();
365  if (MOK != ModuleOwnershipKind::Unowned &&
366  (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
367  return MOK;
368  // If D is not local and we have no local module storage, then we don't
369  // need to track module ownership at all.
370  }
372  }
373 
374 public:
375  Decl() = delete;
376  Decl(const Decl&) = delete;
377  Decl(Decl &&) = delete;
378  Decl &operator=(const Decl&) = delete;
379  Decl &operator=(Decl&&) = delete;
380 
381 protected:
383  : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
384  DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false),
385  Implicit(false), Used(false), Referenced(false),
386  TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
389  if (StatisticsEnabled) add(DK);
390  }
391 
392  Decl(Kind DK, EmptyShell Empty)
393  : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false),
394  Used(false), Referenced(false), TopLevelDeclInObjCContainer(false),
398  if (StatisticsEnabled) add(DK);
399  }
400 
401  virtual ~Decl();
402 
403  /// Update a potentially out-of-date declaration.
404  void updateOutOfDate(IdentifierInfo &II) const;
405 
407  return Linkage(CacheValidAndLinkage - 1);
408  }
409 
410  void setCachedLinkage(Linkage L) const {
411  CacheValidAndLinkage = L + 1;
412  }
413 
414  bool hasCachedLinkage() const {
415  return CacheValidAndLinkage;
416  }
417 
418 public:
419  /// Source range that this declaration covers.
420  virtual SourceRange getSourceRange() const LLVM_READONLY {
421  return SourceRange(getLocation(), getLocation());
422  }
423 
424  SourceLocation getBeginLoc() const LLVM_READONLY {
425  return getSourceRange().getBegin();
426  }
427 
428  SourceLocation getEndLoc() const LLVM_READONLY {
429  return getSourceRange().getEnd();
430  }
431 
432  SourceLocation getLocation() const { return Loc; }
433  void setLocation(SourceLocation L) { Loc = L; }
434 
435  Kind getKind() const { return static_cast<Kind>(DeclKind); }
436  const char *getDeclKindName() const;
437 
438  Decl *getNextDeclInContext() { return NextInContextAndBits.getPointer(); }
439  const Decl *getNextDeclInContext() const {return NextInContextAndBits.getPointer();}
440 
442  if (isInSemaDC())
443  return getSemanticDC();
444  return getMultipleDC()->SemanticDC;
445  }
446  const DeclContext *getDeclContext() const {
447  return const_cast<Decl*>(this)->getDeclContext();
448  }
449 
450  /// Return the non transparent context.
451  /// See the comment of `DeclContext::isTransparentContext()` for the
452  /// definition of transparent context.
455  return const_cast<Decl *>(this)->getNonTransparentDeclContext();
456  }
457 
458  /// Find the innermost non-closure ancestor of this declaration,
459  /// walking up through blocks, lambdas, etc. If that ancestor is
460  /// not a code context (!isFunctionOrMethod()), returns null.
461  ///
462  /// A declaration may be its own non-closure context.
464  const Decl *getNonClosureContext() const {
465  return const_cast<Decl*>(this)->getNonClosureContext();
466  }
467 
470  return const_cast<Decl*>(this)->getTranslationUnitDecl();
471  }
472 
473  bool isInAnonymousNamespace() const;
474 
475  bool isInStdNamespace() const;
476 
477  // Return true if this is a FileContext Decl.
478  bool isFileContextDecl() const;
479 
480  ASTContext &getASTContext() const LLVM_READONLY;
481 
482  /// Helper to get the language options from the ASTContext.
483  /// Defined out of line to avoid depending on ASTContext.h.
484  const LangOptions &getLangOpts() const LLVM_READONLY;
485 
487  Access = AS;
488  assert(AccessDeclContextCheck());
489  }
490 
492  assert(AccessDeclContextCheck());
493  return AccessSpecifier(Access);
494  }
495 
496  /// Retrieve the access specifier for this declaration, even though
497  /// it may not yet have been properly set.
499  return AccessSpecifier(Access);
500  }
501 
502  bool hasAttrs() const { return HasAttrs; }
503 
504  void setAttrs(const AttrVec& Attrs) {
505  return setAttrsImpl(Attrs, getASTContext());
506  }
507 
509  return const_cast<AttrVec&>(const_cast<const Decl*>(this)->getAttrs());
510  }
511 
512  const AttrVec &getAttrs() const;
513  void dropAttrs();
514  void addAttr(Attr *A);
515 
516  using attr_iterator = AttrVec::const_iterator;
517  using attr_range = llvm::iterator_range<attr_iterator>;
518 
519  attr_range attrs() const {
520  return attr_range(attr_begin(), attr_end());
521  }
522 
524  return hasAttrs() ? getAttrs().begin() : nullptr;
525  }
527  return hasAttrs() ? getAttrs().end() : nullptr;
528  }
529 
530  template <typename T>
531  void dropAttr() {
532  if (!HasAttrs) return;
533 
534  AttrVec &Vec = getAttrs();
535  llvm::erase_if(Vec, [](Attr *A) { return isa<T>(A); });
536 
537  if (Vec.empty())
538  HasAttrs = false;
539  }
540 
541  template <typename T>
542  llvm::iterator_range<specific_attr_iterator<T>> specific_attrs() const {
543  return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
544  }
545 
546  template <typename T>
549  }
550 
551  template <typename T>
554  }
555 
556  template<typename T> T *getAttr() const {
557  return hasAttrs() ? getSpecificAttr<T>(getAttrs()) : nullptr;
558  }
559 
560  template<typename T> bool hasAttr() const {
561  return hasAttrs() && hasSpecificAttr<T>(getAttrs());
562  }
563 
564  /// getMaxAlignment - return the maximum alignment specified by attributes
565  /// on this decl, 0 if there are none.
566  unsigned getMaxAlignment() const;
567 
568  /// setInvalidDecl - Indicates the Decl had a semantic error. This
569  /// allows for graceful error recovery.
570  void setInvalidDecl(bool Invalid = true);
571  bool isInvalidDecl() const { return (bool) InvalidDecl; }
572 
573  /// isImplicit - Indicates whether the declaration was implicitly
574  /// generated by the implementation. If false, this declaration
575  /// was written explicitly in the source code.
576  bool isImplicit() const { return Implicit; }
577  void setImplicit(bool I = true) { Implicit = I; }
578 
579  /// Whether *any* (re-)declaration of the entity was used, meaning that
580  /// a definition is required.
581  ///
582  /// \param CheckUsedAttr When true, also consider the "used" attribute
583  /// (in addition to the "used" bit set by \c setUsed()) when determining
584  /// whether the function is used.
585  bool isUsed(bool CheckUsedAttr = true) const;
586 
587  /// Set whether the declaration is used, in the sense of odr-use.
588  ///
589  /// This should only be used immediately after creating a declaration.
590  /// It intentionally doesn't notify any listeners.
591  void setIsUsed() { getCanonicalDecl()->Used = true; }
592 
593  /// Mark the declaration used, in the sense of odr-use.
594  ///
595  /// This notifies any mutation listeners in addition to setting a bit
596  /// indicating the declaration is used.
597  void markUsed(ASTContext &C);
598 
599  /// Whether any declaration of this entity was referenced.
600  bool isReferenced() const;
601 
602  /// Whether this declaration was referenced. This should not be relied
603  /// upon for anything other than debugging.
604  bool isThisDeclarationReferenced() const { return Referenced; }
605 
606  void setReferenced(bool R = true) { Referenced = R; }
607 
608  /// Whether this declaration is a top-level declaration (function,
609  /// global variable, etc.) that is lexically inside an objc container
610  /// definition.
612  return TopLevelDeclInObjCContainer;
613  }
614 
615  void setTopLevelDeclInObjCContainer(bool V = true) {
616  TopLevelDeclInObjCContainer = V;
617  }
618 
619  /// Looks on this and related declarations for an applicable
620  /// external source symbol attribute.
621  ExternalSourceSymbolAttr *getExternalSourceSymbolAttr() const;
622 
623  /// Whether this declaration was marked as being private to the
624  /// module in which it was defined.
625  bool isModulePrivate() const {
627  }
628 
629  /// Whether this declaration was exported in a lexical context.
630  /// e.g.:
631  ///
632  /// export namespace A {
633  /// void f1(); // isInExportDeclContext() == true
634  /// }
635  /// void A::f1(); // isInExportDeclContext() == false
636  ///
637  /// namespace B {
638  /// void f2(); // isInExportDeclContext() == false
639  /// }
640  /// export void B::f2(); // isInExportDeclContext() == true
641  bool isInExportDeclContext() const;
642 
645  }
646 
647  /// FIXME: Implement discarding declarations actually in global module
648  /// fragment. See [module.global.frag]p3,4 for details.
649  bool isDiscardedInGlobalModuleFragment() const { return false; }
650 
651  /// Return true if this declaration has an attribute which acts as
652  /// definition of the entity, such as 'alias' or 'ifunc'.
653  bool hasDefiningAttr() const;
654 
655  /// Return this declaration's defining attribute if it has one.
656  const Attr *getDefiningAttr() const;
657 
658 protected:
659  /// Specify that this declaration was marked as being private
660  /// to the module in which it was defined.
662  // The module-private specifier has no effect on unowned declarations.
663  // FIXME: We should track this in some way for source fidelity.
665  return;
667  }
668 
669 public:
670  /// Set the FromASTFile flag. This indicates that this declaration
671  /// was deserialized and not parsed from source code and enables
672  /// features such as module ownership information.
673  void setFromASTFile() {
674  FromASTFile = true;
675  }
676 
677  /// Set the owning module ID. This may only be called for
678  /// deserialized Decls.
679  void setOwningModuleID(unsigned ID) {
680  assert(isFromASTFile() && "Only works on a deserialized declaration");
681  *((unsigned*)this - 2) = ID;
682  }
683 
684 public:
685  /// Determine the availability of the given declaration.
686  ///
687  /// This routine will determine the most restrictive availability of
688  /// the given declaration (e.g., preferring 'unavailable' to
689  /// 'deprecated').
690  ///
691  /// \param Message If non-NULL and the result is not \c
692  /// AR_Available, will be set to a (possibly empty) message
693  /// describing why the declaration has not been introduced, is
694  /// deprecated, or is unavailable.
695  ///
696  /// \param EnclosingVersion The version to compare with. If empty, assume the
697  /// deployment target version.
698  ///
699  /// \param RealizedPlatform If non-NULL and the availability result is found
700  /// in an available attribute it will set to the platform which is written in
701  /// the available attribute.
703  getAvailability(std::string *Message = nullptr,
704  VersionTuple EnclosingVersion = VersionTuple(),
705  StringRef *RealizedPlatform = nullptr) const;
706 
707  /// Retrieve the version of the target platform in which this
708  /// declaration was introduced.
709  ///
710  /// \returns An empty version tuple if this declaration has no 'introduced'
711  /// availability attributes, or the version tuple that's specified in the
712  /// attribute otherwise.
713  VersionTuple getVersionIntroduced() const;
714 
715  /// Determine whether this declaration is marked 'deprecated'.
716  ///
717  /// \param Message If non-NULL and the declaration is deprecated,
718  /// this will be set to the message describing why the declaration
719  /// was deprecated (which may be empty).
720  bool isDeprecated(std::string *Message = nullptr) const {
721  return getAvailability(Message) == AR_Deprecated;
722  }
723 
724  /// Determine whether this declaration is marked 'unavailable'.
725  ///
726  /// \param Message If non-NULL and the declaration is unavailable,
727  /// this will be set to the message describing why the declaration
728  /// was made unavailable (which may be empty).
729  bool isUnavailable(std::string *Message = nullptr) const {
730  return getAvailability(Message) == AR_Unavailable;
731  }
732 
733  /// Determine whether this is a weak-imported symbol.
734  ///
735  /// Weak-imported symbols are typically marked with the
736  /// 'weak_import' attribute, but may also be marked with an
737  /// 'availability' attribute where we're targing a platform prior to
738  /// the introduction of this feature.
739  bool isWeakImported() const;
740 
741  /// Determines whether this symbol can be weak-imported,
742  /// e.g., whether it would be well-formed to add the weak_import
743  /// attribute.
744  ///
745  /// \param IsDefinition Set to \c true to indicate that this
746  /// declaration cannot be weak-imported because it has a definition.
747  bool canBeWeakImported(bool &IsDefinition) const;
748 
749  /// Determine whether this declaration came from an AST file (such as
750  /// a precompiled header or module) rather than having been parsed.
751  bool isFromASTFile() const { return FromASTFile; }
752 
753  /// Retrieve the global declaration ID associated with this
754  /// declaration, which specifies where this Decl was loaded from.
755  unsigned getGlobalID() const {
756  if (isFromASTFile())
757  return *((const unsigned*)this - 1);
758  return 0;
759  }
760 
761  /// Retrieve the global ID of the module that owns this particular
762  /// declaration.
763  unsigned getOwningModuleID() const {
764  if (isFromASTFile())
765  return *((const unsigned*)this - 2);
766  return 0;
767  }
768 
769 private:
770  Module *getOwningModuleSlow() const;
771 
772 protected:
773  bool hasLocalOwningModuleStorage() const;
774 
775 public:
776  /// Get the imported owning module, if this decl is from an imported
777  /// (non-local) module.
779  if (!isFromASTFile() || !hasOwningModule())
780  return nullptr;
781 
782  return getOwningModuleSlow();
783  }
784 
785  /// Get the local owning module, if known. Returns nullptr if owner is
786  /// not yet known or declaration is not from a module.
788  if (isFromASTFile() || !hasOwningModule())
789  return nullptr;
790 
791  assert(hasLocalOwningModuleStorage() &&
792  "owned local decl but no local module storage");
793  return reinterpret_cast<Module *const *>(this)[-1];
794  }
796  assert(!isFromASTFile() && hasOwningModule() &&
798  "should not have a cached owning module");
799  reinterpret_cast<Module **>(this)[-1] = M;
800  }
801 
802  /// Is this declaration owned by some module?
803  bool hasOwningModule() const {
805  }
806 
807  /// Get the module that owns this declaration (for visibility purposes).
810  }
811 
812  /// Get the module that owns this declaration for linkage purposes.
813  /// There only ever is such a module under the C++ Modules TS.
814  ///
815  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
816  /// all declarations in a global module fragment are unowned.
817  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
818 
819  /// Determine whether this declaration is definitely visible to name lookup,
820  /// independent of whether the owning module is visible.
821  /// Note: The declaration may be visible even if this returns \c false if the
822  /// owning module is visible within the query context. This is a low-level
823  /// helper function; most code should be calling Sema::isVisible() instead.
826  }
827 
828  bool isReachable() const {
829  return (int)getModuleOwnershipKind() <=
831  }
832 
833  /// Set that this declaration is globally visible, even if it came from a
834  /// module that is not visible.
838  }
839 
840  /// Get the kind of module ownership for this declaration.
842  return NextInContextAndBits.getInt();
843  }
844 
845  /// Set whether this declaration is hidden from name lookup.
850  "no storage available for owning module for this declaration");
851  NextInContextAndBits.setInt(MOK);
852  }
853 
854  unsigned getIdentifierNamespace() const {
855  return IdentifierNamespace;
856  }
857 
858  bool isInIdentifierNamespace(unsigned NS) const {
859  return getIdentifierNamespace() & NS;
860  }
861 
862  static unsigned getIdentifierNamespaceForKind(Kind DK);
863 
866  }
867 
868  static bool isTagIdentifierNamespace(unsigned NS) {
869  // TagDecls have Tag and Type set and may also have TagFriend.
870  return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
871  }
872 
873  /// getLexicalDeclContext - The declaration context where this Decl was
874  /// lexically declared (LexicalDC). May be different from
875  /// getDeclContext() (SemanticDC).
876  /// e.g.:
877  ///
878  /// namespace A {
879  /// void f(); // SemanticDC == LexicalDC == 'namespace A'
880  /// }
881  /// void A::f(); // SemanticDC == namespace 'A'
882  /// // LexicalDC == global namespace
884  if (isInSemaDC())
885  return getSemanticDC();
886  return getMultipleDC()->LexicalDC;
887  }
889  return const_cast<Decl*>(this)->getLexicalDeclContext();
890  }
891 
892  /// Determine whether this declaration is declared out of line (outside its
893  /// semantic context).
894  virtual bool isOutOfLine() const;
895 
896  /// setDeclContext - Set both the semantic and lexical DeclContext
897  /// to DC.
898  void setDeclContext(DeclContext *DC);
899 
901 
902  /// Determine whether this declaration is a templated entity (whether it is
903  // within the scope of a template parameter).
904  bool isTemplated() const;
905 
906  /// Determine the number of levels of template parameter surrounding this
907  /// declaration.
908  unsigned getTemplateDepth() const;
909 
910  /// isDefinedOutsideFunctionOrMethod - This predicate returns true if this
911  /// scoped decl is defined outside the current function or method. This is
912  /// roughly global variables and functions, but also handles enums (which
913  /// could be defined inside or outside a function etc).
915  return getParentFunctionOrMethod() == nullptr;
916  }
917 
918  /// Determine whether a substitution into this declaration would occur as
919  /// part of a substitution into a dependent local scope. Such a substitution
920  /// transitively substitutes into all constructs nested within this
921  /// declaration.
922  ///
923  /// This recognizes non-defining declarations as well as members of local
924  /// classes and lambdas:
925  /// \code
926  /// template<typename T> void foo() { void bar(); }
927  /// template<typename T> void foo2() { class ABC { void bar(); }; }
928  /// template<typename T> inline int x = [](){ return 0; }();
929  /// \endcode
930  bool isInLocalScopeForInstantiation() const;
931 
932  /// If this decl is defined inside a function/method/block it returns
933  /// the corresponding DeclContext, otherwise it returns null.
934  const DeclContext *
935  getParentFunctionOrMethod(bool LexicalParent = false) const;
936  DeclContext *getParentFunctionOrMethod(bool LexicalParent = false) {
937  return const_cast<DeclContext *>(
938  const_cast<const Decl *>(this)->getParentFunctionOrMethod(
939  LexicalParent));
940  }
941 
942  /// Retrieves the "canonical" declaration of the given declaration.
943  virtual Decl *getCanonicalDecl() { return this; }
944  const Decl *getCanonicalDecl() const {
945  return const_cast<Decl*>(this)->getCanonicalDecl();
946  }
947 
948  /// Whether this particular Decl is a canonical one.
949  bool isCanonicalDecl() const { return getCanonicalDecl() == this; }
950 
951 protected:
952  /// Returns the next redeclaration or itself if this is the only decl.
953  ///
954  /// Decl subclasses that can be redeclared should override this method so that
955  /// Decl::redecl_iterator can iterate over them.
956  virtual Decl *getNextRedeclarationImpl() { return this; }
957 
958  /// Implementation of getPreviousDecl(), to be overridden by any
959  /// subclass that has a redeclaration chain.
960  virtual Decl *getPreviousDeclImpl() { return nullptr; }
961 
962  /// Implementation of getMostRecentDecl(), to be overridden by any
963  /// subclass that has a redeclaration chain.
964  virtual Decl *getMostRecentDeclImpl() { return this; }
965 
966 public:
967  /// Iterates through all the redeclarations of the same decl.
969  /// Current - The current declaration.
970  Decl *Current = nullptr;
971  Decl *Starter;
972 
973  public:
974  using value_type = Decl *;
975  using reference = const value_type &;
976  using pointer = const value_type *;
977  using iterator_category = std::forward_iterator_tag;
979 
980  redecl_iterator() = default;
981  explicit redecl_iterator(Decl *C) : Current(C), Starter(C) {}
982 
983  reference operator*() const { return Current; }
984  value_type operator->() const { return Current; }
985 
987  assert(Current && "Advancing while iterator has reached end");
988  // Get either previous decl or latest decl.
989  Decl *Next = Current->getNextRedeclarationImpl();
990  assert(Next && "Should return next redeclaration or itself, never null!");
991  Current = (Next != Starter) ? Next : nullptr;
992  return *this;
993  }
994 
996  redecl_iterator tmp(*this);
997  ++(*this);
998  return tmp;
999  }
1000 
1002  return x.Current == y.Current;
1003  }
1004 
1006  return x.Current != y.Current;
1007  }
1008  };
1009 
1010  using redecl_range = llvm::iterator_range<redecl_iterator>;
1011 
1012  /// Returns an iterator range for all the redeclarations of the same
1013  /// decl. It will iterate at least once (when this decl is the only one).
1015  return redecl_range(redecls_begin(), redecls_end());
1016  }
1017 
1019  return redecl_iterator(const_cast<Decl *>(this));
1020  }
1021 
1023 
1024  /// Retrieve the previous declaration that declares the same entity
1025  /// as this declaration, or NULL if there is no previous declaration.
1027 
1028  /// Retrieve the previous declaration that declares the same entity
1029  /// as this declaration, or NULL if there is no previous declaration.
1030  const Decl *getPreviousDecl() const {
1031  return const_cast<Decl *>(this)->getPreviousDeclImpl();
1032  }
1033 
1034  /// True if this is the first declaration in its redeclaration chain.
1035  bool isFirstDecl() const {
1036  return getPreviousDecl() == nullptr;
1037  }
1038 
1039  /// Retrieve the most recent declaration that declares the same entity
1040  /// as this declaration (which may be this declaration).
1042 
1043  /// Retrieve the most recent declaration that declares the same entity
1044  /// as this declaration (which may be this declaration).
1045  const Decl *getMostRecentDecl() const {
1046  return const_cast<Decl *>(this)->getMostRecentDeclImpl();
1047  }
1048 
1049  /// getBody - If this Decl represents a declaration for a body of code,
1050  /// such as a function or method definition, this method returns the
1051  /// top-level Stmt* of that body. Otherwise this method returns null.
1052  virtual Stmt* getBody() const { return nullptr; }
1053 
1054  /// Returns true if this \c Decl represents a declaration for a body of
1055  /// code, such as a function or method definition.
1056  /// Note that \c hasBody can also return true if any redeclaration of this
1057  /// \c Decl represents a declaration for a body of code.
1058  virtual bool hasBody() const { return getBody() != nullptr; }
1059 
1060  /// getBodyRBrace - Gets the right brace of the body, if a body exists.
1061  /// This works whether the body is a CompoundStmt or a CXXTryStmt.
1062  SourceLocation getBodyRBrace() const;
1063 
1064  // global temp stats (until we have a per-module visitor)
1065  static void add(Kind k);
1066  static void EnableStatistics();
1067  static void PrintStats();
1068 
1069  /// isTemplateParameter - Determines whether this declaration is a
1070  /// template parameter.
1071  bool isTemplateParameter() const;
1072 
1073  /// isTemplateParameter - Determines whether this declaration is a
1074  /// template parameter pack.
1075  bool isTemplateParameterPack() const;
1076 
1077  /// Whether this declaration is a parameter pack.
1078  bool isParameterPack() const;
1079 
1080  /// returns true if this declaration is a template
1081  bool isTemplateDecl() const;
1082 
1083  /// Whether this declaration is a function or function template.
1085  return (DeclKind >= Decl::firstFunction &&
1086  DeclKind <= Decl::lastFunction) ||
1087  DeclKind == FunctionTemplate;
1088  }
1089 
1090  /// If this is a declaration that describes some template, this
1091  /// method returns that template declaration.
1092  ///
1093  /// Note that this returns nullptr for partial specializations, because they
1094  /// are not modeled as TemplateDecls. Use getDescribedTemplateParams to handle
1095  /// those cases.
1097 
1098  /// If this is a declaration that describes some template or partial
1099  /// specialization, this returns the corresponding template parameter list.
1101 
1102  /// Returns the function itself, or the templated function if this is a
1103  /// function template.
1104  FunctionDecl *getAsFunction() LLVM_READONLY;
1105 
1106  const FunctionDecl *getAsFunction() const {
1107  return const_cast<Decl *>(this)->getAsFunction();
1108  }
1109 
1110  /// Changes the namespace of this declaration to reflect that it's
1111  /// a function-local extern declaration.
1112  ///
1113  /// These declarations appear in the lexical context of the extern
1114  /// declaration, but in the semantic context of the enclosing namespace
1115  /// scope.
1117  Decl *Prev = getPreviousDecl();
1119 
1120  // It's OK for the declaration to still have the "invisible friend" flag or
1121  // the "conflicts with tag declarations in this scope" flag for the outer
1122  // scope.
1123  assert((IdentifierNamespace & ~(IDNS_OrdinaryFriend | IDNS_Tag)) == 0 &&
1124  "namespace is not ordinary");
1125 
1127  if (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary)
1129  }
1130 
1131  /// Determine whether this is a block-scope declaration with linkage.
1132  /// This will either be a local variable declaration declared 'extern', or a
1133  /// local function declaration.
1134  bool isLocalExternDecl() const {
1136  }
1137 
1138  /// Changes the namespace of this declaration to reflect that it's
1139  /// the object of a friend declaration.
1140  ///
1141  /// These declarations appear in the lexical context of the friending
1142  /// class, but in the semantic context of the actual entity. This property
1143  /// applies only to a specific decl object; other redeclarations of the
1144  /// same entity may not (and probably don't) share this property.
1145  void setObjectOfFriendDecl(bool PerformFriendInjection = false) {
1146  unsigned OldNS = IdentifierNamespace;
1147  assert((OldNS & (IDNS_Tag | IDNS_Ordinary |
1150  "namespace includes neither ordinary nor tag");
1151  assert(!(OldNS & ~(IDNS_Tag | IDNS_Ordinary | IDNS_Type |
1154  "namespace includes other than ordinary or tag");
1155 
1156  Decl *Prev = getPreviousDecl();
1158 
1159  if (OldNS & (IDNS_Tag | IDNS_TagFriend)) {
1161  if (PerformFriendInjection ||
1162  (Prev && Prev->getIdentifierNamespace() & IDNS_Tag))
1164  }
1165 
1166  if (OldNS & (IDNS_Ordinary | IDNS_OrdinaryFriend |
1169  if (PerformFriendInjection ||
1170  (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary))
1172  }
1173  }
1174 
1176  FOK_None, ///< Not a friend object.
1177  FOK_Declared, ///< A friend of a previously-declared entity.
1178  FOK_Undeclared ///< A friend of a previously-undeclared entity.
1179  };
1180 
1181  /// Determines whether this declaration is the object of a
1182  /// friend declaration and, if so, what kind.
1183  ///
1184  /// There is currently no direct way to find the associated FriendDecl.
1186  unsigned mask =
1188  if (!mask) return FOK_None;
1190  : FOK_Undeclared);
1191  }
1192 
1193  /// Specifies that this declaration is a C++ overloaded non-member.
1195  assert(getKind() == Function || getKind() == FunctionTemplate);
1196  assert((IdentifierNamespace & IDNS_Ordinary) &&
1197  "visible non-member operators should be in ordinary namespace");
1199  }
1200 
1201  static bool classofKind(Kind K) { return true; }
1202  static DeclContext *castToDeclContext(const Decl *);
1203  static Decl *castFromDeclContext(const DeclContext *);
1204 
1205  void print(raw_ostream &Out, unsigned Indentation = 0,
1206  bool PrintInstantiation = false) const;
1207  void print(raw_ostream &Out, const PrintingPolicy &Policy,
1208  unsigned Indentation = 0, bool PrintInstantiation = false) const;
1209  static void printGroup(Decl** Begin, unsigned NumDecls,
1210  raw_ostream &Out, const PrintingPolicy &Policy,
1211  unsigned Indentation = 0);
1212 
1213  // Debuggers don't usually respect default arguments.
1214  void dump() const;
1215 
1216  // Same as dump(), but forces color printing.
1217  void dumpColor() const;
1218 
1219  void dump(raw_ostream &Out, bool Deserialize = false,
1220  ASTDumpOutputFormat OutputFormat = ADOF_Default) const;
1221 
1222  /// \return Unique reproducible object identifier
1223  int64_t getID() const;
1224 
1225  /// Looks through the Decl's underlying type to extract a FunctionType
1226  /// when possible. Will return null if the type underlying the Decl does not
1227  /// have a FunctionType.
1228  const FunctionType *getFunctionType(bool BlocksToo = true) const;
1229 
1230 private:
1231  void setAttrsImpl(const AttrVec& Attrs, ASTContext &Ctx);
1232  void setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,
1233  ASTContext &Ctx);
1234 
1235 protected:
1237 };
1238 
1239 /// Determine whether two declarations declare the same entity.
1240 inline bool declaresSameEntity(const Decl *D1, const Decl *D2) {
1241  if (!D1 || !D2)
1242  return false;
1243 
1244  if (D1 == D2)
1245  return true;
1246 
1247  return D1->getCanonicalDecl() == D2->getCanonicalDecl();
1248 }
1249 
1250 /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
1251 /// doing something to a specific decl.
1252 class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
1253  const Decl *TheDecl;
1254  SourceLocation Loc;
1255  SourceManager &SM;
1256  const char *Message;
1257 
1258 public:
1260  SourceManager &sm, const char *Msg)
1261  : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1262 
1263  void print(raw_ostream &OS) const override;
1264 };
1265 } // namespace clang
1266 
1267 // Required to determine the layout of the PointerUnion<NamedDecl*> before
1268 // seeing the NamedDecl definition being first used in DeclListNode::operator*.
1269 namespace llvm {
1270  template <> struct PointerLikeTypeTraits<::clang::NamedDecl *> {
1271  static inline void *getAsVoidPointer(::clang::NamedDecl *P) { return P; }
1272  static inline ::clang::NamedDecl *getFromVoidPointer(void *P) {
1273  return static_cast<::clang::NamedDecl *>(P);
1274  }
1275  static constexpr int NumLowBitsAvailable = 3;
1276  };
1277 }
1278 
1279 namespace clang {
1280 /// A list storing NamedDecls in the lookup tables.
1282  friend class ASTContext; // allocate, deallocate nodes.
1283  friend class StoredDeclsList;
1284 public:
1285  using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>;
1286  class iterator {
1288  friend class StoredDeclsList;
1289 
1290  Decls Ptr;
1291  iterator(Decls Node) : Ptr(Node) { }
1292  public:
1295  using pointer = void;
1297  using iterator_category = std::forward_iterator_tag;
1298 
1299  iterator() = default;
1300 
1302  assert(Ptr && "dereferencing end() iterator");
1303  if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
1304  return CurNode->D;
1305  return Ptr.get<NamedDecl*>();
1306  }
1307  void operator->() const { } // Unsupported.
1308  bool operator==(const iterator &X) const { return Ptr == X.Ptr; }
1309  bool operator!=(const iterator &X) const { return Ptr != X.Ptr; }
1310  inline iterator &operator++() { // ++It
1311  assert(!Ptr.isNull() && "Advancing empty iterator");
1312 
1313  if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
1314  Ptr = CurNode->Rest;
1315  else
1316  Ptr = nullptr;
1317  return *this;
1318  }
1319  iterator operator++(int) { // It++
1320  iterator temp = *this;
1321  ++(*this);
1322  return temp;
1323  }
1324  // Enables the pattern for (iterator I =..., E = I.end(); I != E; ++I)
1325  iterator end() { return iterator(); }
1326  };
1327 private:
1328  NamedDecl *D = nullptr;
1329  Decls Rest = nullptr;
1330  DeclListNode(NamedDecl *ND) : D(ND) {}
1331 };
1332 
1333 /// The results of name lookup within a DeclContext.
1335  using Decls = DeclListNode::Decls;
1336 
1337  /// When in collection form, this is what the Data pointer points to.
1338  Decls Result;
1339 
1340 public:
1341  DeclContextLookupResult() = default;
1342  DeclContextLookupResult(Decls Result) : Result(Result) {}
1343 
1347 
1348  iterator begin() { return iterator(Result); }
1349  iterator end() { return iterator(); }
1351  return const_cast<DeclContextLookupResult*>(this)->begin();
1352  }
1353  const_iterator end() const { return iterator(); }
1354 
1355  bool empty() const { return Result.isNull(); }
1356  bool isSingleResult() const { return Result.dyn_cast<NamedDecl*>(); }
1357  reference front() const { return *begin(); }
1358 
1359  // Find the first declaration of the given type in the list. Note that this
1360  // is not in general the earliest-declared declaration, and should only be
1361  // used when it's not possible for there to be more than one match or where
1362  // it doesn't matter which one is found.
1363  template<class T> T *find_first() const {
1364  for (auto *D : *this)
1365  if (T *Decl = dyn_cast<T>(D))
1366  return Decl;
1367 
1368  return nullptr;
1369  }
1370 };
1371 
1372 /// DeclContext - This is used only as base class of specific decl types that
1373 /// can act as declaration contexts. These decls are (only the top classes
1374 /// that directly derive from DeclContext are mentioned, not their subclasses):
1375 ///
1376 /// TranslationUnitDecl
1377 /// ExternCContext
1378 /// NamespaceDecl
1379 /// TagDecl
1380 /// OMPDeclareReductionDecl
1381 /// OMPDeclareMapperDecl
1382 /// FunctionDecl
1383 /// ObjCMethodDecl
1384 /// ObjCContainerDecl
1385 /// LinkageSpecDecl
1386 /// ExportDecl
1387 /// BlockDecl
1388 /// CapturedDecl
1390  /// For makeDeclVisibleInContextImpl
1391  friend class ASTDeclReader;
1392  /// For reconcileExternalVisibleStorage, CreateStoredDeclsMap,
1393  /// hasNeedToReconcileExternalVisibleStorage
1394  friend class ExternalASTSource;
1395  /// For CreateStoredDeclsMap
1396  friend class DependentDiagnostic;
1397  /// For hasNeedToReconcileExternalVisibleStorage,
1398  /// hasLazyLocalLexicalLookups, hasLazyExternalLexicalLookups
1399  friend class ASTWriter;
1400 
1401  // We use uint64_t in the bit-fields below since some bit-fields
1402  // cross the unsigned boundary and this breaks the packing.
1403 
1404  /// Stores the bits used by DeclContext.
1405  /// If modified NumDeclContextBit, the ctor of DeclContext and the accessor
1406  /// methods in DeclContext should be updated appropriately.
1407  class DeclContextBitfields {
1408  friend class DeclContext;
1409  /// DeclKind - This indicates which class this is.
1410  uint64_t DeclKind : 7;
1411 
1412  /// Whether this declaration context also has some external
1413  /// storage that contains additional declarations that are lexically
1414  /// part of this context.
1415  mutable uint64_t ExternalLexicalStorage : 1;
1416 
1417  /// Whether this declaration context also has some external
1418  /// storage that contains additional declarations that are visible
1419  /// in this context.
1420  mutable uint64_t ExternalVisibleStorage : 1;
1421 
1422  /// Whether this declaration context has had externally visible
1423  /// storage added since the last lookup. In this case, \c LookupPtr's
1424  /// invariant may not hold and needs to be fixed before we perform
1425  /// another lookup.
1426  mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1427 
1428  /// If \c true, this context may have local lexical declarations
1429  /// that are missing from the lookup table.
1430  mutable uint64_t HasLazyLocalLexicalLookups : 1;
1431 
1432  /// If \c true, the external source may have lexical declarations
1433  /// that are missing from the lookup table.
1434  mutable uint64_t HasLazyExternalLexicalLookups : 1;
1435 
1436  /// If \c true, lookups should only return identifier from
1437  /// DeclContext scope (for example TranslationUnit). Used in
1438  /// LookupQualifiedName()
1439  mutable uint64_t UseQualifiedLookup : 1;
1440  };
1441 
1442  /// Number of bits in DeclContextBitfields.
1443  enum { NumDeclContextBits = 13 };
1444 
1445  /// Stores the bits used by TagDecl.
1446  /// If modified NumTagDeclBits and the accessor
1447  /// methods in TagDecl should be updated appropriately.
1448  class TagDeclBitfields {
1449  friend class TagDecl;
1450  /// For the bits in DeclContextBitfields
1451  uint64_t : NumDeclContextBits;
1452 
1453  /// The TagKind enum.
1454  uint64_t TagDeclKind : 3;
1455 
1456  /// True if this is a definition ("struct foo {};"), false if it is a
1457  /// declaration ("struct foo;"). It is not considered a definition
1458  /// until the definition has been fully processed.
1459  uint64_t IsCompleteDefinition : 1;
1460 
1461  /// True if this is currently being defined.
1462  uint64_t IsBeingDefined : 1;
1463 
1464  /// True if this tag declaration is "embedded" (i.e., defined or declared
1465  /// for the very first time) in the syntax of a declarator.
1466  uint64_t IsEmbeddedInDeclarator : 1;
1467 
1468  /// True if this tag is free standing, e.g. "struct foo;".
1469  uint64_t IsFreeStanding : 1;
1470 
1471  /// Indicates whether it is possible for declarations of this kind
1472  /// to have an out-of-date definition.
1473  ///
1474  /// This option is only enabled when modules are enabled.
1475  uint64_t MayHaveOutOfDateDef : 1;
1476 
1477  /// Has the full definition of this type been required by a use somewhere in
1478  /// the TU.
1479  uint64_t IsCompleteDefinitionRequired : 1;
1480 
1481  /// Whether this tag is a definition which was demoted due to
1482  /// a module merge.
1483  uint64_t IsThisDeclarationADemotedDefinition : 1;
1484  };
1485 
1486  /// Number of non-inherited bits in TagDeclBitfields.
1487  enum { NumTagDeclBits = 10 };
1488 
1489  /// Stores the bits used by EnumDecl.
1490  /// If modified NumEnumDeclBit and the accessor
1491  /// methods in EnumDecl should be updated appropriately.
1492  class EnumDeclBitfields {
1493  friend class EnumDecl;
1494  /// For the bits in DeclContextBitfields.
1495  uint64_t : NumDeclContextBits;
1496  /// For the bits in TagDeclBitfields.
1497  uint64_t : NumTagDeclBits;
1498 
1499  /// Width in bits required to store all the non-negative
1500  /// enumerators of this enum.
1501  uint64_t NumPositiveBits : 8;
1502 
1503  /// Width in bits required to store all the negative
1504  /// enumerators of this enum.
1505  uint64_t NumNegativeBits : 8;
1506 
1507  /// True if this tag declaration is a scoped enumeration. Only
1508  /// possible in C++11 mode.
1509  uint64_t IsScoped : 1;
1510 
1511  /// If this tag declaration is a scoped enum,
1512  /// then this is true if the scoped enum was declared using the class
1513  /// tag, false if it was declared with the struct tag. No meaning is
1514  /// associated if this tag declaration is not a scoped enum.
1515  uint64_t IsScopedUsingClassTag : 1;
1516 
1517  /// True if this is an enumeration with fixed underlying type. Only
1518  /// possible in C++11, Microsoft extensions, or Objective C mode.
1519  uint64_t IsFixed : 1;
1520 
1521  /// True if a valid hash is stored in ODRHash.
1522  uint64_t HasODRHash : 1;
1523  };
1524 
1525  /// Number of non-inherited bits in EnumDeclBitfields.
1526  enum { NumEnumDeclBits = 20 };
1527 
1528  /// Stores the bits used by RecordDecl.
1529  /// If modified NumRecordDeclBits and the accessor
1530  /// methods in RecordDecl should be updated appropriately.
1531  class RecordDeclBitfields {
1532  friend class RecordDecl;
1533  /// For the bits in DeclContextBitfields.
1534  uint64_t : NumDeclContextBits;
1535  /// For the bits in TagDeclBitfields.
1536  uint64_t : NumTagDeclBits;
1537 
1538  /// This is true if this struct ends with a flexible
1539  /// array member (e.g. int X[]) or if this union contains a struct that does.
1540  /// If so, this cannot be contained in arrays or other structs as a member.
1541  uint64_t HasFlexibleArrayMember : 1;
1542 
1543  /// Whether this is the type of an anonymous struct or union.
1544  uint64_t AnonymousStructOrUnion : 1;
1545 
1546  /// This is true if this struct has at least one member
1547  /// containing an Objective-C object pointer type.
1548  uint64_t HasObjectMember : 1;
1549 
1550  /// This is true if struct has at least one member of
1551  /// 'volatile' type.
1552  uint64_t HasVolatileMember : 1;
1553 
1554  /// Whether the field declarations of this record have been loaded
1555  /// from external storage. To avoid unnecessary deserialization of
1556  /// methods/nested types we allow deserialization of just the fields
1557  /// when needed.
1558  mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1559 
1560  /// Basic properties of non-trivial C structs.
1561  uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1562  uint64_t NonTrivialToPrimitiveCopy : 1;
1563  uint64_t NonTrivialToPrimitiveDestroy : 1;
1564 
1565  /// The following bits indicate whether this is or contains a C union that
1566  /// is non-trivial to default-initialize, destruct, or copy. These bits
1567  /// imply the associated basic non-triviality predicates declared above.
1568  uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
1569  uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
1570  uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
1571 
1572  /// Indicates whether this struct is destroyed in the callee.
1573  uint64_t ParamDestroyedInCallee : 1;
1574 
1575  /// Represents the way this type is passed to a function.
1576  uint64_t ArgPassingRestrictions : 2;
1577 
1578  /// Indicates whether this struct has had its field layout randomized.
1579  uint64_t IsRandomized : 1;
1580 
1581  /// True if a valid hash is stored in ODRHash. This should shave off some
1582  /// extra storage and prevent CXXRecordDecl to store unused bits.
1583  uint64_t ODRHash : 26;
1584  };
1585 
1586  /// Number of non-inherited bits in RecordDeclBitfields.
1587  enum { NumRecordDeclBits = 41 };
1588 
1589  /// Stores the bits used by OMPDeclareReductionDecl.
1590  /// If modified NumOMPDeclareReductionDeclBits and the accessor
1591  /// methods in OMPDeclareReductionDecl should be updated appropriately.
1592  class OMPDeclareReductionDeclBitfields {
1593  friend class OMPDeclareReductionDecl;
1594  /// For the bits in DeclContextBitfields
1595  uint64_t : NumDeclContextBits;
1596 
1597  /// Kind of initializer,
1598  /// function call or omp_priv<init_expr> initializtion.
1599  uint64_t InitializerKind : 2;
1600  };
1601 
1602  /// Number of non-inherited bits in OMPDeclareReductionDeclBitfields.
1603  enum { NumOMPDeclareReductionDeclBits = 2 };
1604 
1605  /// Stores the bits used by FunctionDecl.
1606  /// If modified NumFunctionDeclBits and the accessor
1607  /// methods in FunctionDecl and CXXDeductionGuideDecl
1608  /// (for IsCopyDeductionCandidate) should be updated appropriately.
1609  class FunctionDeclBitfields {
1610  friend class FunctionDecl;
1611  /// For IsCopyDeductionCandidate
1612  friend class CXXDeductionGuideDecl;
1613  /// For the bits in DeclContextBitfields.
1614  uint64_t : NumDeclContextBits;
1615 
1616  uint64_t SClass : 3;
1617  uint64_t IsInline : 1;
1618  uint64_t IsInlineSpecified : 1;
1619 
1620  uint64_t IsVirtualAsWritten : 1;
1621  uint64_t IsPure : 1;
1622  uint64_t HasInheritedPrototype : 1;
1623  uint64_t HasWrittenPrototype : 1;
1624  uint64_t IsDeleted : 1;
1625  /// Used by CXXMethodDecl
1626  uint64_t IsTrivial : 1;
1627 
1628  /// This flag indicates whether this function is trivial for the purpose of
1629  /// calls. This is meaningful only when this function is a copy/move
1630  /// constructor or a destructor.
1631  uint64_t IsTrivialForCall : 1;
1632 
1633  uint64_t IsDefaulted : 1;
1634  uint64_t IsExplicitlyDefaulted : 1;
1635  uint64_t HasDefaultedFunctionInfo : 1;
1636 
1637  /// For member functions of complete types, whether this is an ineligible
1638  /// special member function or an unselected destructor. See
1639  /// [class.mem.special].
1640  uint64_t IsIneligibleOrNotSelected : 1;
1641 
1642  uint64_t HasImplicitReturnZero : 1;
1643  uint64_t IsLateTemplateParsed : 1;
1644 
1645  /// Kind of contexpr specifier as defined by ConstexprSpecKind.
1646  uint64_t ConstexprKind : 2;
1647  uint64_t InstantiationIsPending : 1;
1648 
1649  /// Indicates if the function uses __try.
1650  uint64_t UsesSEHTry : 1;
1651 
1652  /// Indicates if the function was a definition
1653  /// but its body was skipped.
1654  uint64_t HasSkippedBody : 1;
1655 
1656  /// Indicates if the function declaration will
1657  /// have a body, once we're done parsing it.
1658  uint64_t WillHaveBody : 1;
1659 
1660  /// Indicates that this function is a multiversioned
1661  /// function using attribute 'target'.
1662  uint64_t IsMultiVersion : 1;
1663 
1664  /// [C++17] Only used by CXXDeductionGuideDecl. Indicates that
1665  /// the Deduction Guide is the implicitly generated 'copy
1666  /// deduction candidate' (is used during overload resolution).
1667  uint64_t IsCopyDeductionCandidate : 1;
1668 
1669  /// Store the ODRHash after first calculation.
1670  uint64_t HasODRHash : 1;
1671 
1672  /// Indicates if the function uses Floating Point Constrained Intrinsics
1673  uint64_t UsesFPIntrin : 1;
1674 
1675  // Indicates this function is a constrained friend, where the constraint
1676  // refers to an enclosing template for hte purposes of [temp.friend]p9.
1677  uint64_t FriendConstraintRefersToEnclosingTemplate : 1;
1678  };
1679 
1680  /// Number of non-inherited bits in FunctionDeclBitfields.
1681  enum { NumFunctionDeclBits = 29 };
1682 
1683  /// Stores the bits used by CXXConstructorDecl. If modified
1684  /// NumCXXConstructorDeclBits and the accessor
1685  /// methods in CXXConstructorDecl should be updated appropriately.
1686  class CXXConstructorDeclBitfields {
1687  friend class CXXConstructorDecl;
1688  /// For the bits in DeclContextBitfields.
1689  uint64_t : NumDeclContextBits;
1690  /// For the bits in FunctionDeclBitfields.
1691  uint64_t : NumFunctionDeclBits;
1692 
1693  /// 22 bits to fit in the remaining available space.
1694  /// Note that this makes CXXConstructorDeclBitfields take
1695  /// exactly 64 bits and thus the width of NumCtorInitializers
1696  /// will need to be shrunk if some bit is added to NumDeclContextBitfields,
1697  /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
1698  uint64_t NumCtorInitializers : 19;
1699  uint64_t IsInheritingConstructor : 1;
1700 
1701  /// Whether this constructor has a trail-allocated explicit specifier.
1702  uint64_t HasTrailingExplicitSpecifier : 1;
1703  /// If this constructor does't have a trail-allocated explicit specifier.
1704  /// Whether this constructor is explicit specified.
1705  uint64_t IsSimpleExplicit : 1;
1706  };
1707 
1708  /// Number of non-inherited bits in CXXConstructorDeclBitfields.
1709  enum {
1710  NumCXXConstructorDeclBits = 64 - NumDeclContextBits - NumFunctionDeclBits
1711  };
1712 
1713  /// Stores the bits used by ObjCMethodDecl.
1714  /// If modified NumObjCMethodDeclBits and the accessor
1715  /// methods in ObjCMethodDecl should be updated appropriately.
1716  class ObjCMethodDeclBitfields {
1717  friend class ObjCMethodDecl;
1718 
1719  /// For the bits in DeclContextBitfields.
1720  uint64_t : NumDeclContextBits;
1721 
1722  /// The conventional meaning of this method; an ObjCMethodFamily.
1723  /// This is not serialized; instead, it is computed on demand and
1724  /// cached.
1725  mutable uint64_t Family : ObjCMethodFamilyBitWidth;
1726 
1727  /// instance (true) or class (false) method.
1728  uint64_t IsInstance : 1;
1729  uint64_t IsVariadic : 1;
1730 
1731  /// True if this method is the getter or setter for an explicit property.
1732  uint64_t IsPropertyAccessor : 1;
1733 
1734  /// True if this method is a synthesized property accessor stub.
1735  uint64_t IsSynthesizedAccessorStub : 1;
1736 
1737  /// Method has a definition.
1738  uint64_t IsDefined : 1;
1739 
1740  /// Method redeclaration in the same interface.
1741  uint64_t IsRedeclaration : 1;
1742 
1743  /// Is redeclared in the same interface.
1744  mutable uint64_t HasRedeclaration : 1;
1745 
1746  /// \@required/\@optional
1747  uint64_t DeclImplementation : 2;
1748 
1749  /// in, inout, etc.
1750  uint64_t objcDeclQualifier : 7;
1751 
1752  /// Indicates whether this method has a related result type.
1753  uint64_t RelatedResultType : 1;
1754 
1755  /// Whether the locations of the selector identifiers are in a
1756  /// "standard" position, a enum SelectorLocationsKind.
1757  uint64_t SelLocsKind : 2;
1758 
1759  /// Whether this method overrides any other in the class hierarchy.
1760  ///
1761  /// A method is said to override any method in the class's
1762  /// base classes, its protocols, or its categories' protocols, that has
1763  /// the same selector and is of the same kind (class or instance).
1764  /// A method in an implementation is not considered as overriding the same
1765  /// method in the interface or its categories.
1766  uint64_t IsOverriding : 1;
1767 
1768  /// Indicates if the method was a definition but its body was skipped.
1769  uint64_t HasSkippedBody : 1;
1770  };
1771 
1772  /// Number of non-inherited bits in ObjCMethodDeclBitfields.
1773  enum { NumObjCMethodDeclBits = 24 };
1774 
1775  /// Stores the bits used by ObjCContainerDecl.
1776  /// If modified NumObjCContainerDeclBits and the accessor
1777  /// methods in ObjCContainerDecl should be updated appropriately.
1778  class ObjCContainerDeclBitfields {
1779  friend class ObjCContainerDecl;
1780  /// For the bits in DeclContextBitfields
1781  uint32_t : NumDeclContextBits;
1782 
1783  // Not a bitfield but this saves space.
1784  // Note that ObjCContainerDeclBitfields is full.
1785  SourceLocation AtStart;
1786  };
1787 
1788  /// Number of non-inherited bits in ObjCContainerDeclBitfields.
1789  /// Note that here we rely on the fact that SourceLocation is 32 bits
1790  /// wide. We check this with the static_assert in the ctor of DeclContext.
1791  enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1792 
1793  /// Stores the bits used by LinkageSpecDecl.
1794  /// If modified NumLinkageSpecDeclBits and the accessor
1795  /// methods in LinkageSpecDecl should be updated appropriately.
1796  class LinkageSpecDeclBitfields {
1797  friend class LinkageSpecDecl;
1798  /// For the bits in DeclContextBitfields.
1799  uint64_t : NumDeclContextBits;
1800 
1801  /// The language for this linkage specification with values
1802  /// in the enum LinkageSpecDecl::LanguageIDs.
1803  uint64_t Language : 3;
1804 
1805  /// True if this linkage spec has braces.
1806  /// This is needed so that hasBraces() returns the correct result while the
1807  /// linkage spec body is being parsed. Once RBraceLoc has been set this is
1808  /// not used, so it doesn't need to be serialized.
1809  uint64_t HasBraces : 1;
1810  };
1811 
1812  /// Number of non-inherited bits in LinkageSpecDeclBitfields.
1813  enum { NumLinkageSpecDeclBits = 4 };
1814 
1815  /// Stores the bits used by BlockDecl.
1816  /// If modified NumBlockDeclBits and the accessor
1817  /// methods in BlockDecl should be updated appropriately.
1818  class BlockDeclBitfields {
1819  friend class BlockDecl;
1820  /// For the bits in DeclContextBitfields.
1821  uint64_t : NumDeclContextBits;
1822 
1823  uint64_t IsVariadic : 1;
1824  uint64_t CapturesCXXThis : 1;
1825  uint64_t BlockMissingReturnType : 1;
1826  uint64_t IsConversionFromLambda : 1;
1827 
1828  /// A bit that indicates this block is passed directly to a function as a
1829  /// non-escaping parameter.
1830  uint64_t DoesNotEscape : 1;
1831 
1832  /// A bit that indicates whether it's possible to avoid coying this block to
1833  /// the heap when it initializes or is assigned to a local variable with
1834  /// automatic storage.
1835  uint64_t CanAvoidCopyToHeap : 1;
1836  };
1837 
1838  /// Number of non-inherited bits in BlockDeclBitfields.
1839  enum { NumBlockDeclBits = 5 };
1840 
1841  /// Pointer to the data structure used to lookup declarations
1842  /// within this context (or a DependentStoredDeclsMap if this is a
1843  /// dependent context). We maintain the invariant that, if the map
1844  /// contains an entry for a DeclarationName (and we haven't lazily
1845  /// omitted anything), then it contains all relevant entries for that
1846  /// name (modulo the hasExternalDecls() flag).
1847  mutable StoredDeclsMap *LookupPtr = nullptr;
1848 
1849 protected:
1850  /// This anonymous union stores the bits belonging to DeclContext and classes
1851  /// deriving from it. The goal is to use otherwise wasted
1852  /// space in DeclContext to store data belonging to derived classes.
1853  /// The space saved is especially significient when pointers are aligned
1854  /// to 8 bytes. In this case due to alignment requirements we have a
1855  /// little less than 8 bytes free in DeclContext which we can use.
1856  /// We check that none of the classes in this union is larger than
1857  /// 8 bytes with static_asserts in the ctor of DeclContext.
1858  union {
1859  DeclContextBitfields DeclContextBits;
1860  TagDeclBitfields TagDeclBits;
1861  EnumDeclBitfields EnumDeclBits;
1862  RecordDeclBitfields RecordDeclBits;
1863  OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits;
1864  FunctionDeclBitfields FunctionDeclBits;
1865  CXXConstructorDeclBitfields CXXConstructorDeclBits;
1866  ObjCMethodDeclBitfields ObjCMethodDeclBits;
1867  ObjCContainerDeclBitfields ObjCContainerDeclBits;
1868  LinkageSpecDeclBitfields LinkageSpecDeclBits;
1869  BlockDeclBitfields BlockDeclBits;
1870 
1871  static_assert(sizeof(DeclContextBitfields) <= 8,
1872  "DeclContextBitfields is larger than 8 bytes!");
1873  static_assert(sizeof(TagDeclBitfields) <= 8,
1874  "TagDeclBitfields is larger than 8 bytes!");
1875  static_assert(sizeof(EnumDeclBitfields) <= 8,
1876  "EnumDeclBitfields is larger than 8 bytes!");
1877  static_assert(sizeof(RecordDeclBitfields) <= 8,
1878  "RecordDeclBitfields is larger than 8 bytes!");
1879  static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8,
1880  "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
1881  static_assert(sizeof(FunctionDeclBitfields) <= 8,
1882  "FunctionDeclBitfields is larger than 8 bytes!");
1883  static_assert(sizeof(CXXConstructorDeclBitfields) <= 8,
1884  "CXXConstructorDeclBitfields is larger than 8 bytes!");
1885  static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
1886  "ObjCMethodDeclBitfields is larger than 8 bytes!");
1887  static_assert(sizeof(ObjCContainerDeclBitfields) <= 8,
1888  "ObjCContainerDeclBitfields is larger than 8 bytes!");
1889  static_assert(sizeof(LinkageSpecDeclBitfields) <= 8,
1890  "LinkageSpecDeclBitfields is larger than 8 bytes!");
1891  static_assert(sizeof(BlockDeclBitfields) <= 8,
1892  "BlockDeclBitfields is larger than 8 bytes!");
1893  };
1894 
1895  /// FirstDecl - The first declaration stored within this declaration
1896  /// context.
1897  mutable Decl *FirstDecl = nullptr;
1898 
1899  /// LastDecl - The last declaration stored within this declaration
1900  /// context. FIXME: We could probably cache this value somewhere
1901  /// outside of the DeclContext, to reduce the size of DeclContext by
1902  /// another pointer.
1903  mutable Decl *LastDecl = nullptr;
1904 
1905  /// Build up a chain of declarations.
1906  ///
1907  /// \returns the first/last pair of declarations.
1908  static std::pair<Decl *, Decl *>
1909  BuildDeclChain(ArrayRef<Decl*> Decls, bool FieldsAlreadyLoaded);
1910 
1912 
1913 public:
1914  ~DeclContext();
1915 
1916  // For use when debugging; hasValidDeclKind() will always return true for
1917  // a correctly constructed object within its lifetime.
1918  bool hasValidDeclKind() const;
1919 
1921  return static_cast<Decl::Kind>(DeclContextBits.DeclKind);
1922  }
1923 
1924  const char *getDeclKindName() const;
1925 
1926  /// getParent - Returns the containing DeclContext.
1928  return cast<Decl>(this)->getDeclContext();
1929  }
1930  const DeclContext *getParent() const {
1931  return const_cast<DeclContext*>(this)->getParent();
1932  }
1933 
1934  /// getLexicalParent - Returns the containing lexical DeclContext. May be
1935  /// different from getParent, e.g.:
1936  ///
1937  /// namespace A {
1938  /// struct S;
1939  /// }
1940  /// struct A::S {}; // getParent() == namespace 'A'
1941  /// // getLexicalParent() == translation unit
1942  ///
1944  return cast<Decl>(this)->getLexicalDeclContext();
1945  }
1947  return const_cast<DeclContext*>(this)->getLexicalParent();
1948  }
1949 
1951 
1952  const DeclContext *getLookupParent() const {
1953  return const_cast<DeclContext*>(this)->getLookupParent();
1954  }
1955 
1957  return cast<Decl>(this)->getASTContext();
1958  }
1959 
1960  bool isClosure() const { return getDeclKind() == Decl::Block; }
1961 
1962  /// Return this DeclContext if it is a BlockDecl. Otherwise, return the
1963  /// innermost enclosing BlockDecl or null if there are no enclosing blocks.
1964  const BlockDecl *getInnermostBlockDecl() const;
1965 
1966  bool isObjCContainer() const {
1967  switch (getDeclKind()) {
1968  case Decl::ObjCCategory:
1969  case Decl::ObjCCategoryImpl:
1970  case Decl::ObjCImplementation:
1971  case Decl::ObjCInterface:
1972  case Decl::ObjCProtocol:
1973  return true;
1974  default:
1975  return false;
1976  }
1977  }
1978 
1979  bool isFunctionOrMethod() const {
1980  switch (getDeclKind()) {
1981  case Decl::Block:
1982  case Decl::Captured:
1983  case Decl::ObjCMethod:
1984  return true;
1985  default:
1986  return getDeclKind() >= Decl::firstFunction &&
1987  getDeclKind() <= Decl::lastFunction;
1988  }
1989  }
1990 
1991  /// Test whether the context supports looking up names.
1992  bool isLookupContext() const {
1993  return !isFunctionOrMethod() && getDeclKind() != Decl::LinkageSpec &&
1994  getDeclKind() != Decl::Export;
1995  }
1996 
1997  bool isFileContext() const {
1998  return getDeclKind() == Decl::TranslationUnit ||
1999  getDeclKind() == Decl::Namespace;
2000  }
2001 
2002  bool isTranslationUnit() const {
2003  return getDeclKind() == Decl::TranslationUnit;
2004  }
2005 
2006  bool isRecord() const {
2007  return getDeclKind() >= Decl::firstRecord &&
2008  getDeclKind() <= Decl::lastRecord;
2009  }
2010 
2011  bool isNamespace() const { return getDeclKind() == Decl::Namespace; }
2012 
2013  bool isStdNamespace() const;
2014 
2015  bool isInlineNamespace() const;
2016 
2017  /// Determines whether this context is dependent on a
2018  /// template parameter.
2019  bool isDependentContext() const;
2020 
2021  /// isTransparentContext - Determines whether this context is a
2022  /// "transparent" context, meaning that the members declared in this
2023  /// context are semantically declared in the nearest enclosing
2024  /// non-transparent (opaque) context but are lexically declared in
2025  /// this context. For example, consider the enumerators of an
2026  /// enumeration type:
2027  /// @code
2028  /// enum E {
2029  /// Val1
2030  /// };
2031  /// @endcode
2032  /// Here, E is a transparent context, so its enumerator (Val1) will
2033  /// appear (semantically) that it is in the same context of E.
2034  /// Examples of transparent contexts include: enumerations (except for
2035  /// C++0x scoped enums), C++ linkage specifications and export declaration.
2036  bool isTransparentContext() const;
2037 
2038  /// Determines whether this context or some of its ancestors is a
2039  /// linkage specification context that specifies C linkage.
2040  bool isExternCContext() const;
2041 
2042  /// Retrieve the nearest enclosing C linkage specification context.
2043  const LinkageSpecDecl *getExternCContext() const;
2044 
2045  /// Determines whether this context or some of its ancestors is a
2046  /// linkage specification context that specifies C++ linkage.
2047  bool isExternCXXContext() const;
2048 
2049  /// Determine whether this declaration context is equivalent
2050  /// to the declaration context DC.
2051  bool Equals(const DeclContext *DC) const {
2052  return DC && this->getPrimaryContext() == DC->getPrimaryContext();
2053  }
2054 
2055  /// Determine whether this declaration context encloses the
2056  /// declaration context DC.
2057  bool Encloses(const DeclContext *DC) const;
2058 
2059  /// Find the nearest non-closure ancestor of this context,
2060  /// i.e. the innermost semantic parent of this context which is not
2061  /// a closure. A context may be its own non-closure ancestor.
2063  const Decl *getNonClosureAncestor() const {
2064  return const_cast<DeclContext*>(this)->getNonClosureAncestor();
2065  }
2066 
2067  // Retrieve the nearest context that is not a transparent context.
2070  return const_cast<DeclContext *>(this)->getNonTransparentContext();
2071  }
2072 
2073  /// getPrimaryContext - There may be many different
2074  /// declarations of the same entity (including forward declarations
2075  /// of classes, multiple definitions of namespaces, etc.), each with
2076  /// a different set of declarations. This routine returns the
2077  /// "primary" DeclContext structure, which will contain the
2078  /// information needed to perform name lookup into this context.
2081  return const_cast<DeclContext*>(this)->getPrimaryContext();
2082  }
2083 
2084  /// getRedeclContext - Retrieve the context in which an entity conflicts with
2085  /// other entities of the same name, or where it is a redeclaration if the
2086  /// two entities are compatible. This skips through transparent contexts.
2089  return const_cast<DeclContext *>(this)->getRedeclContext();
2090  }
2091 
2092  /// Retrieve the nearest enclosing namespace context.
2095  return const_cast<DeclContext *>(this)->getEnclosingNamespaceContext();
2096  }
2097 
2098  /// Retrieve the outermost lexically enclosing record context.
2101  return const_cast<DeclContext *>(this)->getOuterLexicalRecordContext();
2102  }
2103 
2104  /// Test if this context is part of the enclosing namespace set of
2105  /// the context NS, as defined in C++0x [namespace.def]p9. If either context
2106  /// isn't a namespace, this is equivalent to Equals().
2107  ///
2108  /// The enclosing namespace set of a namespace is the namespace and, if it is
2109  /// inline, its enclosing namespace, recursively.
2110  bool InEnclosingNamespaceSetOf(const DeclContext *NS) const;
2111 
2112  /// Collects all of the declaration contexts that are semantically
2113  /// connected to this declaration context.
2114  ///
2115  /// For declaration contexts that have multiple semantically connected but
2116  /// syntactically distinct contexts, such as C++ namespaces, this routine
2117  /// retrieves the complete set of such declaration contexts in source order.
2118  /// For example, given:
2119  ///
2120  /// \code
2121  /// namespace N {
2122  /// int x;
2123  /// }
2124  /// namespace N {
2125  /// int y;
2126  /// }
2127  /// \endcode
2128  ///
2129  /// The \c Contexts parameter will contain both definitions of N.
2130  ///
2131  /// \param Contexts Will be cleared and set to the set of declaration
2132  /// contexts that are semanticaly connected to this declaration context,
2133  /// in source order, including this context (which may be the only result,
2134  /// for non-namespace contexts).
2136 
2137  /// decl_iterator - Iterates through the declarations stored
2138  /// within this context.
2140  /// Current - The current declaration.
2141  Decl *Current = nullptr;
2142 
2143  public:
2144  using value_type = Decl *;
2145  using reference = const value_type &;
2146  using pointer = const value_type *;
2147  using iterator_category = std::forward_iterator_tag;
2149 
2150  decl_iterator() = default;
2151  explicit decl_iterator(Decl *C) : Current(C) {}
2152 
2153  reference operator*() const { return Current; }
2154 
2155  // This doesn't meet the iterator requirements, but it's convenient
2156  value_type operator->() const { return Current; }
2157 
2159  Current = Current->getNextDeclInContext();
2160  return *this;
2161  }
2162 
2164  decl_iterator tmp(*this);
2165  ++(*this);
2166  return tmp;
2167  }
2168 
2170  return x.Current == y.Current;
2171  }
2172 
2174  return x.Current != y.Current;
2175  }
2176  };
2177 
2178  using decl_range = llvm::iterator_range<decl_iterator>;
2179 
2180  /// decls_begin/decls_end - Iterate over the declarations stored in
2181  /// this context.
2183  decl_iterator decls_begin() const;
2184  decl_iterator decls_end() const { return decl_iterator(); }
2185  bool decls_empty() const;
2186 
2187  /// noload_decls_begin/end - Iterate over the declarations stored in this
2188  /// context that are currently loaded; don't attempt to retrieve anything
2189  /// from an external source.
2192  }
2195 
2196  /// specific_decl_iterator - Iterates over a subrange of
2197  /// declarations stored in a DeclContext, providing only those that
2198  /// are of type SpecificDecl (or a class derived from it). This
2199  /// iterator is used, for example, to provide iteration over just
2200  /// the fields within a RecordDecl (with SpecificDecl = FieldDecl).
2201  template<typename SpecificDecl>
2203  /// Current - The current, underlying declaration iterator, which
2204  /// will either be NULL or will point to a declaration of
2205  /// type SpecificDecl.
2207 
2208  /// SkipToNextDecl - Advances the current position up to the next
2209  /// declaration of type SpecificDecl that also meets the criteria
2210  /// required by Acceptable.
2211  void SkipToNextDecl() {
2212  while (*Current && !isa<SpecificDecl>(*Current))
2213  ++Current;
2214  }
2215 
2216  public:
2217  using value_type = SpecificDecl *;
2218  // TODO: Add reference and pointer types (with some appropriate proxy type)
2219  // if we ever have a need for them.
2220  using reference = void;
2221  using pointer = void;
2222  using difference_type =
2223  std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2224  using iterator_category = std::forward_iterator_tag;
2225 
2226  specific_decl_iterator() = default;
2227 
2228  /// specific_decl_iterator - Construct a new iterator over a
2229  /// subset of the declarations the range [C,
2230  /// end-of-declarations). If A is non-NULL, it is a pointer to a
2231  /// member function of SpecificDecl that should return true for
2232  /// all of the SpecificDecl instances that will be in the subset
2233  /// of iterators. For example, if you want Objective-C instance
2234  /// methods, SpecificDecl will be ObjCMethodDecl and A will be
2235  /// &ObjCMethodDecl::isInstanceMethod.
2237  SkipToNextDecl();
2238  }
2239 
2240  value_type operator*() const { return cast<SpecificDecl>(*Current); }
2241 
2242  // This doesn't meet the iterator requirements, but it's convenient
2243  value_type operator->() const { return **this; }
2244 
2246  ++Current;
2247  SkipToNextDecl();
2248  return *this;
2249  }
2250 
2252  specific_decl_iterator tmp(*this);
2253  ++(*this);
2254  return tmp;
2255  }
2256 
2258  const specific_decl_iterator& y) {
2259  return x.Current == y.Current;
2260  }
2261 
2263  const specific_decl_iterator& y) {
2264  return x.Current != y.Current;
2265  }
2266  };
2267 
2268  /// Iterates over a filtered subrange of declarations stored
2269  /// in a DeclContext.
2270  ///
2271  /// This iterator visits only those declarations that are of type
2272  /// SpecificDecl (or a class derived from it) and that meet some
2273  /// additional run-time criteria. This iterator is used, for
2274  /// example, to provide access to the instance methods within an
2275  /// Objective-C interface (with SpecificDecl = ObjCMethodDecl and
2276  /// Acceptable = ObjCMethodDecl::isInstanceMethod).
2277  template<typename SpecificDecl, bool (SpecificDecl::*Acceptable)() const>
2279  /// Current - The current, underlying declaration iterator, which
2280  /// will either be NULL or will point to a declaration of
2281  /// type SpecificDecl.
2283 
2284  /// SkipToNextDecl - Advances the current position up to the next
2285  /// declaration of type SpecificDecl that also meets the criteria
2286  /// required by Acceptable.
2287  void SkipToNextDecl() {
2288  while (*Current &&
2289  (!isa<SpecificDecl>(*Current) ||
2290  (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2291  ++Current;
2292  }
2293 
2294  public:
2295  using value_type = SpecificDecl *;
2296  // TODO: Add reference and pointer types (with some appropriate proxy type)
2297  // if we ever have a need for them.
2298  using reference = void;
2299  using pointer = void;
2300  using difference_type =
2301  std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2302  using iterator_category = std::forward_iterator_tag;
2303 
2304  filtered_decl_iterator() = default;
2305 
2306  /// filtered_decl_iterator - Construct a new iterator over a
2307  /// subset of the declarations the range [C,
2308  /// end-of-declarations). If A is non-NULL, it is a pointer to a
2309  /// member function of SpecificDecl that should return true for
2310  /// all of the SpecificDecl instances that will be in the subset
2311  /// of iterators. For example, if you want Objective-C instance
2312  /// methods, SpecificDecl will be ObjCMethodDecl and A will be
2313  /// &ObjCMethodDecl::isInstanceMethod.
2315  SkipToNextDecl();
2316  }
2317 
2318  value_type operator*() const { return cast<SpecificDecl>(*Current); }
2319  value_type operator->() const { return cast<SpecificDecl>(*Current); }
2320 
2322  ++Current;
2323  SkipToNextDecl();
2324  return *this;
2325  }
2326 
2328  filtered_decl_iterator tmp(*this);
2329  ++(*this);
2330  return tmp;
2331  }
2332 
2334  const filtered_decl_iterator& y) {
2335  return x.Current == y.Current;
2336  }
2337 
2339  const filtered_decl_iterator& y) {
2340  return x.Current != y.Current;
2341  }
2342  };
2343 
2344  /// Add the declaration D into this context.
2345  ///
2346  /// This routine should be invoked when the declaration D has first
2347  /// been declared, to place D into the context where it was
2348  /// (lexically) defined. Every declaration must be added to one
2349  /// (and only one!) context, where it can be visited via
2350  /// [decls_begin(), decls_end()). Once a declaration has been added
2351  /// to its lexical context, the corresponding DeclContext owns the
2352  /// declaration.
2353  ///
2354  /// If D is also a NamedDecl, it will be made visible within its
2355  /// semantic context via makeDeclVisibleInContext.
2356  void addDecl(Decl *D);
2357 
2358  /// Add the declaration D into this context, but suppress
2359  /// searches for external declarations with the same name.
2360  ///
2361  /// Although analogous in function to addDecl, this removes an
2362  /// important check. This is only useful if the Decl is being
2363  /// added in response to an external search; in all other cases,
2364  /// addDecl() is the right function to use.
2365  /// See the ASTImporter for use cases.
2366  void addDeclInternal(Decl *D);
2367 
2368  /// Add the declaration D to this context without modifying
2369  /// any lookup tables.
2370  ///
2371  /// This is useful for some operations in dependent contexts where
2372  /// the semantic context might not be dependent; this basically
2373  /// only happens with friends.
2374  void addHiddenDecl(Decl *D);
2375 
2376  /// Removes a declaration from this context.
2377  void removeDecl(Decl *D);
2378 
2379  /// Checks whether a declaration is in this context.
2380  bool containsDecl(Decl *D) const;
2381 
2382  /// Checks whether a declaration is in this context.
2383  /// This also loads the Decls from the external source before the check.
2384  bool containsDeclAndLoad(Decl *D) const;
2385 
2388 
2389  /// lookup - Find the declarations (if any) with the given Name in
2390  /// this context. Returns a range of iterators that contains all of
2391  /// the declarations with this name, with object, function, member,
2392  /// and enumerator names preceding any tag name. Note that this
2393  /// routine will not look into parent contexts.
2394  lookup_result lookup(DeclarationName Name) const;
2395 
2396  /// Find the declarations with the given name that are visible
2397  /// within this context; don't attempt to retrieve anything from an
2398  /// external source.
2400 
2401  /// A simplistic name lookup mechanism that performs name lookup
2402  /// into this declaration context without consulting the external source.
2403  ///
2404  /// This function should almost never be used, because it subverts the
2405  /// usual relationship between a DeclContext and the external source.
2406  /// See the ASTImporter for the (few, but important) use cases.
2407  ///
2408  /// FIXME: This is very inefficient; replace uses of it with uses of
2409  /// noload_lookup.
2411  SmallVectorImpl<NamedDecl *> &Results);
2412 
2413  /// Makes a declaration visible within this context.
2414  ///
2415  /// This routine makes the declaration D visible to name lookup
2416  /// within this context and, if this is a transparent context,
2417  /// within its parent contexts up to the first enclosing
2418  /// non-transparent context. Making a declaration visible within a
2419  /// context does not transfer ownership of a declaration, and a
2420  /// declaration can be visible in many contexts that aren't its
2421  /// lexical context.
2422  ///
2423  /// If D is a redeclaration of an existing declaration that is
2424  /// visible from this context, as determined by
2425  /// NamedDecl::declarationReplaces, the previous declaration will be
2426  /// replaced with D.
2428 
2429  /// all_lookups_iterator - An iterator that provides a view over the results
2430  /// of looking up every possible name.
2431  class all_lookups_iterator;
2432 
2433  using lookups_range = llvm::iterator_range<all_lookups_iterator>;
2434 
2435  lookups_range lookups() const;
2436  // Like lookups(), but avoids loading external declarations.
2437  // If PreserveInternalState, avoids building lookup data structures too.
2438  lookups_range noload_lookups(bool PreserveInternalState) const;
2439 
2440  /// Iterators over all possible lookups within this context.
2443 
2444  /// Iterators over all possible lookups within this context that are
2445  /// currently loaded; don't attempt to retrieve anything from an external
2446  /// source.
2449 
2450  struct udir_iterator;
2451 
2452  using udir_iterator_base =
2453  llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
2456 
2459 
2460  UsingDirectiveDecl *operator*() const;
2461  };
2462 
2463  using udir_range = llvm::iterator_range<udir_iterator>;
2464 
2465  udir_range using_directives() const;
2466 
2467  // These are all defined in DependentDiagnostic.h.
2468  class ddiag_iterator;
2469 
2470  using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2471 
2472  inline ddiag_range ddiags() const;
2473 
2474  // Low-level accessors
2475 
2476  /// Mark that there are external lexical declarations that we need
2477  /// to include in our lookup table (and that are not available as external
2478  /// visible lookups). These extra lookup results will be found by walking
2479  /// the lexical declarations of this context. This should be used only if
2480  /// setHasExternalLexicalStorage() has been called on any decl context for
2481  /// which this is the primary context.
2483  assert(this == getPrimaryContext() &&
2484  "should only be called on primary context");
2485  DeclContextBits.HasLazyExternalLexicalLookups = true;
2486  }
2487 
2488  /// Retrieve the internal representation of the lookup structure.
2489  /// This may omit some names if we are lazily building the structure.
2490  StoredDeclsMap *getLookupPtr() const { return LookupPtr; }
2491 
2492  /// Ensure the lookup structure is fully-built and return it.
2494 
2495  /// Whether this DeclContext has external storage containing
2496  /// additional declarations that are lexically in this context.
2498  return DeclContextBits.ExternalLexicalStorage;
2499  }
2500 
2501  /// State whether this DeclContext has external storage for
2502  /// declarations lexically in this context.
2503  void setHasExternalLexicalStorage(bool ES = true) const {
2504  DeclContextBits.ExternalLexicalStorage = ES;
2505  }
2506 
2507  /// Whether this DeclContext has external storage containing
2508  /// additional declarations that are visible in this context.
2510  return DeclContextBits.ExternalVisibleStorage;
2511  }
2512 
2513  /// State whether this DeclContext has external storage for
2514  /// declarations visible in this context.
2515  void setHasExternalVisibleStorage(bool ES = true) const {
2516  DeclContextBits.ExternalVisibleStorage = ES;
2517  if (ES && LookupPtr)
2518  DeclContextBits.NeedToReconcileExternalVisibleStorage = true;
2519  }
2520 
2521  /// Determine whether the given declaration is stored in the list of
2522  /// declarations lexically within this context.
2523  bool isDeclInLexicalTraversal(const Decl *D) const {
2524  return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl ||
2525  D == LastDecl);
2526  }
2527 
2528  bool setUseQualifiedLookup(bool use = true) const {
2529  bool old_value = DeclContextBits.UseQualifiedLookup;
2530  DeclContextBits.UseQualifiedLookup = use;
2531  return old_value;
2532  }
2533 
2535  return DeclContextBits.UseQualifiedLookup;
2536  }
2537 
2538  static bool classof(const Decl *D);
2539  static bool classof(const DeclContext *D) { return true; }
2540 
2541  void dumpAsDecl() const;
2542  void dumpAsDecl(const ASTContext *Ctx) const;
2543  void dumpDeclContext() const;
2544  void dumpLookups() const;
2545  void dumpLookups(llvm::raw_ostream &OS, bool DumpDecls = false,
2546  bool Deserialize = false) const;
2547 
2548 private:
2549  /// Whether this declaration context has had externally visible
2550  /// storage added since the last lookup. In this case, \c LookupPtr's
2551  /// invariant may not hold and needs to be fixed before we perform
2552  /// another lookup.
2553  bool hasNeedToReconcileExternalVisibleStorage() const {
2554  return DeclContextBits.NeedToReconcileExternalVisibleStorage;
2555  }
2556 
2557  /// State that this declaration context has had externally visible
2558  /// storage added since the last lookup. In this case, \c LookupPtr's
2559  /// invariant may not hold and needs to be fixed before we perform
2560  /// another lookup.
2561  void setNeedToReconcileExternalVisibleStorage(bool Need = true) const {
2562  DeclContextBits.NeedToReconcileExternalVisibleStorage = Need;
2563  }
2564 
2565  /// If \c true, this context may have local lexical declarations
2566  /// that are missing from the lookup table.
2567  bool hasLazyLocalLexicalLookups() const {
2568  return DeclContextBits.HasLazyLocalLexicalLookups;
2569  }
2570 
2571  /// If \c true, this context may have local lexical declarations
2572  /// that are missing from the lookup table.
2573  void setHasLazyLocalLexicalLookups(bool HasLLLL = true) const {
2574  DeclContextBits.HasLazyLocalLexicalLookups = HasLLLL;
2575  }
2576 
2577  /// If \c true, the external source may have lexical declarations
2578  /// that are missing from the lookup table.
2579  bool hasLazyExternalLexicalLookups() const {
2580  return DeclContextBits.HasLazyExternalLexicalLookups;
2581  }
2582 
2583  /// If \c true, the external source may have lexical declarations
2584  /// that are missing from the lookup table.
2585  void setHasLazyExternalLexicalLookups(bool HasLELL = true) const {
2586  DeclContextBits.HasLazyExternalLexicalLookups = HasLELL;
2587  }
2588 
2589  void reconcileExternalVisibleStorage() const;
2590  bool LoadLexicalDeclsFromExternalStorage() const;
2591 
2592  /// Makes a declaration visible within this context, but
2593  /// suppresses searches for external declarations with the same
2594  /// name.
2595  ///
2596  /// Analogous to makeDeclVisibleInContext, but for the exclusive
2597  /// use of addDeclInternal().
2598  void makeDeclVisibleInContextInternal(NamedDecl *D);
2599 
2600  StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
2601 
2602  void loadLazyLocalLexicalLookups();
2603  void buildLookupImpl(DeclContext *DCtx, bool Internal);
2604  void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
2605  bool Rediscoverable);
2606  void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal);
2607 };
2608 
2609 inline bool Decl::isTemplateParameter() const {
2610  return getKind() == TemplateTypeParm || getKind() == NonTypeTemplateParm ||
2611  getKind() == TemplateTemplateParm;
2612 }
2613 
2614 // Specialization selected when ToTy is not a known subclass of DeclContext.
2615 template <class ToTy,
2616  bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2618  static const ToTy *doit(const DeclContext *Val) {
2619  return static_cast<const ToTy*>(Decl::castFromDeclContext(Val));
2620  }
2621 
2622  static ToTy *doit(DeclContext *Val) {
2623  return static_cast<ToTy*>(Decl::castFromDeclContext(Val));
2624  }
2625 };
2626 
2627 // Specialization selected when ToTy is a known subclass of DeclContext.
2628 template <class ToTy>
2630  static const ToTy *doit(const DeclContext *Val) {
2631  return static_cast<const ToTy*>(Val);
2632  }
2633 
2634  static ToTy *doit(DeclContext *Val) {
2635  return static_cast<ToTy*>(Val);
2636  }
2637 };
2638 
2639 } // namespace clang
2640 
2641 namespace llvm {
2642 
2643 /// isa<T>(DeclContext*)
2644 template <typename To>
2645 struct isa_impl<To, ::clang::DeclContext> {
2646  static bool doit(const ::clang::DeclContext &Val) {
2647  return To::classofKind(Val.getDeclKind());
2648  }
2649 };
2650 
2651 /// cast<T>(DeclContext*)
2652 template<class ToTy>
2653 struct cast_convert_val<ToTy,
2654  const ::clang::DeclContext,const ::clang::DeclContext> {
2655  static const ToTy &doit(const ::clang::DeclContext &Val) {
2657  }
2658 };
2659 
2660 template<class ToTy>
2661 struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> {
2662  static ToTy &doit(::clang::DeclContext &Val) {
2664  }
2665 };
2666 
2667 template<class ToTy>
2668 struct cast_convert_val<ToTy,
2669  const ::clang::DeclContext*, const ::clang::DeclContext*> {
2670  static const ToTy *doit(const ::clang::DeclContext *Val) {
2671  return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2672  }
2673 };
2674 
2675 template<class ToTy>
2676 struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> {
2677  static ToTy *doit(::clang::DeclContext *Val) {
2678  return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2679  }
2680 };
2681 
2682 /// Implement cast_convert_val for Decl -> DeclContext conversions.
2683 template<class FromTy>
2684 struct cast_convert_val< ::clang::DeclContext, FromTy, FromTy> {
2685  static ::clang::DeclContext &doit(const FromTy &Val) {
2686  return *FromTy::castToDeclContext(&Val);
2687  }
2688 };
2689 
2690 template<class FromTy>
2691 struct cast_convert_val< ::clang::DeclContext, FromTy*, FromTy*> {
2692  static ::clang::DeclContext *doit(const FromTy *Val) {
2693  return FromTy::castToDeclContext(Val);
2694  }
2695 };
2696 
2697 template<class FromTy>
2698 struct cast_convert_val< const ::clang::DeclContext, FromTy, FromTy> {
2699  static const ::clang::DeclContext &doit(const FromTy &Val) {
2700  return *FromTy::castToDeclContext(&Val);
2701  }
2702 };
2703 
2704 template<class FromTy>
2705 struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> {
2706  static const ::clang::DeclContext *doit(const FromTy *Val) {
2707  return FromTy::castToDeclContext(Val);
2708  }
2709 };
2710 
2711 } // namespace llvm
2712 
2713 #endif // LLVM_CLANG_AST_DECLBASE_H
clang::Decl::setLexicalDeclContext
void setLexicalDeclContext(DeclContext *DC)
Definition: DeclBase.cpp:340
clang::DeclContext::dumpAsDecl
void dumpAsDecl() const
Definition: ASTDumper.cpp:231
clang::DeclContext::noload_decls_end
decl_iterator noload_decls_end() const
Definition: DeclBase.h:2194
clang::DeclContext::hasExternalVisibleStorage
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:2509
clang::DeclContext::localUncachedLookup
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
Definition: DeclBase.cpp:1790
clang::DeclContextLookupResult::DeclContextLookupResult
DeclContextLookupResult(Decls Result)
Definition: DeclBase.h:1342
clang::Decl::getNonClosureContext
const Decl * getNonClosureContext() const
Definition: DeclBase.h:464
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
clang::DeclContext::decls_end
decl_iterator decls_end() const
Definition: DeclBase.h:2184
clang::DeclContext::removeDecl
void removeDecl(Decl *D)
Removes a declaration from this context.
Definition: DeclBase.cpp:1526
clang::Decl::IDNS_Type
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
Definition: DeclBase.h:127
clang::Decl::FriendObjectKind
FriendObjectKind
Definition: DeclBase.h:1175
clang::Decl::specific_attr_end
specific_attr_iterator< T > specific_attr_end() const
Definition: DeclBase.h:552
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::DeclContext::specific_decl_iterator::specific_decl_iterator
specific_decl_iterator()=default
clang::Decl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:424
clang::DeclContext::getParentASTContext
ASTContext & getParentASTContext() const
Definition: DeclBase.h:1956
clang::Decl::isUnavailable
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
Definition: DeclBase.h:729
clang::DeclContext::getExternCContext
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
Definition: DeclBase.cpp:1229
clang::DeclContext::decls
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2182
clang::Decl::setDeclContext
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:336
Specifiers.h
clang::Decl::hasCachedLinkage
bool hasCachedLinkage() const
Definition: DeclBase.h:414
clang::DeclContext::specific_decl_iterator
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2202
clang::DeclContextLookupResult::end
const_iterator end() const
Definition: DeclBase.h:1353
clang::DeclContext::getNonClosureAncestor
const Decl * getNonClosureAncestor() const
Definition: DeclBase.h:2063
clang::DeclContext::hasExternalLexicalStorage
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:2497
clang::Decl::getEndLoc
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:428
clang::LinkageSpecDecl
Represents a linkage specification.
Definition: DeclCXX.h:2844
clang::DeclContext::addHiddenDecl
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
Definition: DeclBase.cpp:1581
clang::Decl::isTemplateDecl
bool isTemplateDecl() const
returns true if this declaration is a template
Definition: DeclBase.cpp:235
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::DeclContext::ObjCContainerDeclBits
ObjCContainerDeclBitfields ObjCContainerDeclBits
Definition: DeclBase.h:1867
clang::Decl::getImportedOwningModule
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:778
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:23
clang::DeclListNode::iterator::operator!=
bool operator!=(const iterator &X) const
Definition: DeclBase.h:1309
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::cast_convert_decl_context< ToTy, true >::doit
static const ToTy * doit(const DeclContext *Val)
Definition: DeclBase.h:2630
clang::Decl::redecl_iterator::operator++
redecl_iterator & operator++()
Definition: DeclBase.h:986
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:560
clang::DeclContext::OMPDeclareReductionDeclBits
OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits
Definition: DeclBase.h:1863
clang::Decl::getNextRedeclarationImpl
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
Definition: DeclBase.h:956
clang::Redeclarable
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
llvm::cast_convert_val< ToTy, ::clang::DeclContext, ::clang::DeclContext >::doit
static ToTy & doit(::clang::DeclContext &Val)
Definition: DeclBase.h:2662
clang::DeclContext::all_lookups_iterator
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
Definition: DeclLookups.h:28
clang::DeclContext::decl_iterator::operator*
reference operator*() const
Definition: DeclBase.h:2153
clang::Decl::isTemplateParameter
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Definition: DeclBase.h:2609
clang::Decl::getAsFunction
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:227
clang::Decl::Decl
Decl()=delete
Used
@ Used
Definition: ObjCUnusedIVarsChecker.cpp:29
clang::Decl::isOutOfLine
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:100
clang::DeclContext::getParent
const DeclContext * getParent() const
Definition: DeclBase.h:1930
clang::DeclContext::getNonClosureAncestor
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
Definition: DeclBase.cpp:1081
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2929
clang::DeclContext::BlockDeclBits
BlockDeclBitfields BlockDeclBits
Definition: DeclBase.h:1869
clang::Decl::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:438
llvm::SmallVector
Definition: LLVM.h:38
clang::AR_Deprecated
@ AR_Deprecated
Definition: DeclBase.h:72
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::Decl::redecls_begin
redecl_iterator redecls_begin() const
Definition: DeclBase.h:1018
clang::Decl::isDiscardedInGlobalModuleFragment
bool isDiscardedInGlobalModuleFragment() const
FIXME: Implement discarding declarations actually in global module fragment.
Definition: DeclBase.h:649
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::DeclContext::getPrimaryContext
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1264
clang::Decl::ModuleOwnershipKind::ModulePrivate
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::Decl::NextInContextAndBits
llvm::PointerIntPair< Decl *, 3, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
Definition: DeclBase.h:246
clang::Decl::add
static void add(Kind k)
Definition: DeclBase.cpp:202
clang::DeclContextLookupResult::isSingleResult
bool isSingleResult() const
Definition: DeclBase.h:1356
clang::DeclContext::addDeclInternal
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
Definition: DeclBase.cpp:1615
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::Decl::IDNS_Using
@ IDNS_Using
This declaration is a using declaration.
Definition: DeclBase.h:160
clang::Decl::PrintStats
static void PrintStats()
Definition: DeclBase.cpp:178
clang::Decl::getCachedLinkage
Linkage getCachedLinkage() const
Definition: DeclBase.h:406
clang::Decl::hasBody
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:1058
clang::DeclContextLookupResult::begin
const_iterator begin() const
Definition: DeclBase.h:1350
clang::DeclContext::decl_iterator::operator->
value_type operator->() const
Definition: DeclBase.h:2156
clang::Decl::redecl_range
llvm::iterator_range< redecl_iterator > redecl_range
Definition: DeclBase.h:1010
clang::Decl::getNextDeclInContext
Decl * getNextDeclInContext()
Definition: DeclBase.h:438
clang::DeclListNode::iterator
Definition: DeclBase.h:1286
clang::Decl::OBJC_TQ_Out
@ OBJC_TQ_Out
Definition: DeclBase.h:199
llvm::cast_convert_val< ToTy, const ::clang::DeclContext, const ::clang::DeclContext >::doit
static const ToTy & doit(const ::clang::DeclContext &Val)
Definition: DeclBase.h:2655
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::Decl::isUsed
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:457
AttrIterator.h
clang::DeclContext::filtered_decl_iterator::difference_type
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
Definition: DeclBase.h:2301
clang::Decl::getLexicalDeclContext
const DeclContext * getLexicalDeclContext() const
Definition: DeclBase.h:888
clang::Decl::getIdentifierNamespace
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:854
clang::Decl::isTemplateParameterPack
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
Definition: DeclBase.cpp:210
clang::Decl::setTopLevelDeclInObjCContainer
void setTopLevelDeclInObjCContainer(bool V=true)
Definition: DeclBase.h:615
clang::DeclContext::decl_iterator::decl_iterator
decl_iterator()=default
clang::Decl::redecl_iterator::difference_type
std::ptrdiff_t difference_type
Definition: DeclBase.h:978
clang::DeclContext::setHasExternalLexicalStorage
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context.
Definition: DeclBase.h:2503
clang::DeclContext::dumpDeclContext
void dumpDeclContext() const
Definition: DeclPrinter.cpp:220
clang::Decl::getOwningModuleForLinkage
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
Definition: Decl.cpp:1580
clang::Decl::getParentFunctionOrMethod
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
Definition: DeclBase.cpp:295
clang::Decl::isLocalExternDecl
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
Definition: DeclBase.h:1134
clang::Decl::getLangOpts
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
Definition: DeclBase.cpp:434
clang::Decl::setIsUsed
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
Definition: DeclBase.h:591
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:556
clang::DeclContext::filtered_decl_iterator::operator++
filtered_decl_iterator operator++(int)
Definition: DeclBase.h:2327
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::DeclContext::isInlineNamespace
bool isInlineNamespace() const
Definition: DeclBase.cpp:1153
clang::DeclContext::using_directives
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
Definition: DeclBase.cpp:1981
clang::DeclContext::getLexicalParent
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition: DeclBase.h:1943
clang::DeclContext::getLookupParent
const DeclContext * getLookupParent() const
Definition: DeclBase.h:1952
clang::DeclContext::ObjCMethodDeclBits
ObjCMethodDeclBitfields ObjCMethodDeclBits
Definition: DeclBase.h:1866
clang::DeclContext::classof
static bool classof(const Decl *D)
Definition: DeclBase.cpp:1099
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3680
clang::Decl::isTopLevelDeclInObjCContainer
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition: DeclBase.h:611
llvm::PointerLikeTypeTraits<::clang::NamedDecl * >::getFromVoidPointer
static inline ::clang::NamedDecl * getFromVoidPointer(void *P)
Definition: DeclBase.h:1272
clang::Decl::isDeprecated
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
Definition: DeclBase.h:720
llvm::cast_convert_val< ::clang::DeclContext, FromTy, FromTy >::doit
::clang::DeclContext & doit(const FromTy &Val)
Definition: DeclBase.h:2685
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::Decl::isReferenced
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:482
clang::DeclContext::isClosure
bool isClosure() const
Definition: DeclBase.h:1960
clang::DeclContextLookupResult::begin
iterator begin()
Definition: DeclBase.h:1348
clang::Decl::markUsed
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Definition: DeclBase.cpp:472
clang::DeclContext::specific_decl_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2224
clang::Decl::redecl_iterator::operator*
reference operator*() const
Definition: DeclBase.h:983
clang::Decl::OBJC_TQ_Byref
@ OBJC_TQ_Byref
Definition: DeclBase.h:201
clang::Decl::hasTagIdentifierNamespace
bool hasTagIdentifierNamespace() const
Definition: DeclBase.h:864
clang::DeclContext::udir_iterator
Definition: DeclBase.h:2457
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:638
clang::DeclContext::decls_empty
bool decls_empty() const
Definition: DeclBase.cpp:1469
clang::DeclContext::decl_iterator::operator++
decl_iterator & operator++()
Definition: DeclBase.h:2158
clang::Decl::getModuleOwnershipKind
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Definition: DeclBase.h:841
llvm::cast_convert_val< ToTy, const ::clang::DeclContext *, const ::clang::DeclContext * >::doit
static const ToTy * doit(const ::clang::DeclContext *Val)
Definition: DeclBase.h:2670
clang::Decl::IDNS_TagFriend
@ IDNS_TagFriend
This declaration is a friend class.
Definition: DeclBase.h:154
clang::Decl::attr_end
attr_iterator attr_end() const
Definition: DeclBase.h:526
clang::DeclContext::getNonTransparentContext
DeclContext * getNonTransparentContext()
Definition: DeclBase.cpp:1255
clang::DeclContext::specific_decl_iterator::reference
void reference
Definition: DeclBase.h:2220
clang::Decl::getAvailability
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
Definition: DeclBase.cpp:636
clang::Decl::OBJC_TQ_Bycopy
@ OBJC_TQ_Bycopy
Definition: DeclBase.h:200
clang::Decl::isWeakImported
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
Definition: DeclBase.cpp:731
clang::DeclContext::noload_decls
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:2190
clang::Decl::ModuleOwnershipKind
ModuleOwnershipKind
The kind of ownership a declaration has, for visibility purposes.
Definition: DeclBase.h:213
clang::AS_none
@ AS_none
Definition: Specifiers.h:115
clang::DeclListNode::iterator::end
iterator end()
Definition: DeclBase.h:1325
clang::DeclContext::InEnclosingNamespaceSetOf
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
Definition: DeclBase.cpp:1866
clang::DeclContext::specific_decl_iterator::operator->
value_type operator->() const
Definition: DeclBase.h:2243
size_t
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:137
clang::Decl::getFunctionType
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
Definition: DeclBase.cpp:1032
clang::Decl::isThisDeclarationReferenced
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition: DeclBase.h:604
clang::DeclContext::lookups_range
llvm::iterator_range< all_lookups_iterator > lookups_range
Definition: DeclBase.h:2433
clang::Decl::isFileContextDecl
bool isFileContextDecl() const
Definition: DeclBase.cpp:408
clang::DeclListNode::iterator::operator*
reference operator*() const
Definition: DeclBase.h:1301
clang::DeclContext::BuildDeclChain
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
Definition: DeclBase.cpp:1364
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:883
clang::DeclContext::setUseQualifiedLookup
bool setUseQualifiedLookup(bool use=true) const
Definition: DeclBase.h:2528
llvm::cast_convert_val< ::clang::DeclContext, FromTy *, FromTy * >::doit
::clang::DeclContext * doit(const FromTy *Val)
Definition: DeclBase.h:2692
clang::DeclContext::filtered_decl_iterator::reference
void reference
Definition: DeclBase.h:2298
V
#define V(N, I)
Definition: ASTContext.h:3211
clang::TranslationUnitDecl
The top declaration context.
Definition: Decl.h:80
clang::Decl::getGlobalID
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Definition: DeclBase.h:755
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::Decl::getIdentifierNamespaceForKind
static unsigned getIdentifierNamespaceForKind(Kind DK)
Definition: DeclBase.cpp:750
clang::Decl::isFunctionOrFunctionTemplate
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
Definition: DeclBase.h:1084
clang::DeclContext::decl_iterator::operator==
friend bool operator==(decl_iterator x, decl_iterator y)
Definition: DeclBase.h:2169
clang::DeclContext::specific_decl_iterator::specific_decl_iterator
specific_decl_iterator(DeclContext::decl_iterator C)
specific_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
Definition: DeclBase.h:2236
clang::DeclContext::noload_lookups_begin
all_lookups_iterator noload_lookups_begin() const
Iterators over all possible lookups within this context that are currently loaded; don't attempt to r...
clang::DeclContext::FirstDecl
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
Definition: DeclBase.h:1897
clang::AR_Available
@ AR_Available
Definition: DeclBase.h:70
clang::Module
Describes a module or submodule.
Definition: Module.h:98
clang::DeclContext::isObjCContainer
bool isObjCContainer() const
Definition: DeclBase.h:1966
clang::DeclContext::lookups
lookups_range lookups() const
Definition: DeclLookups.h:75
clang::Decl::IdentifierNamespace
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition: DeclBase.h:112
clang::Linkage
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
clang::Decl::getAccess
AccessSpecifier getAccess() const
Definition: DeclBase.h:491
Node
DynTypedNode Node
Definition: ASTMatchFinder.cpp:68
clang::Decl::specific_attrs
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:542
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4332
clang::Decl::getNextDeclInContext
const Decl * getNextDeclInContext() const
Definition: DeclBase.h:439
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:435
clang::DeclListNode::iterator::pointer
void pointer
Definition: DeclBase.h:1295
clang::Decl::getNonClosureContext
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
Definition: DeclBase.cpp:1077
clang::Decl::ModuleOwnershipKind::VisibleWhenImported
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
clang::DeclContext::getEnclosingNamespaceContext
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Definition: DeclBase.cpp:1847
clang::Decl::setAccess
void setAccess(AccessSpecifier AS)
Definition: DeclBase.h:486
clang::Decl::printGroup
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
Definition: DeclPrinter.cpp:188
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::DeclContext::specific_decl_iterator::operator++
specific_decl_iterator operator++(int)
Definition: DeclBase.h:2251
clang::DeclContext::getDeclKind
Decl::Kind getDeclKind() const
Definition: DeclBase.h:1920
clang::DeclContext::specific_decl_iterator::pointer
void pointer
Definition: DeclBase.h:2221
clang::Decl::FOK_None
@ FOK_None
Not a friend object.
Definition: DeclBase.h:1176
clang::Decl::isInStdNamespace
bool isInStdNamespace() const
Definition: DeclBase.cpp:403
clang::Decl::setModuleOwnershipKind
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
Definition: DeclBase.h:846
clang::StoredDeclsMap
Definition: DeclContextInternals.h:296
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::Decl::ObjCDeclQualifier
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:195
clang::DeclContext::decl_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2147
clang::Decl::setAttrs
void setAttrs(const AttrVec &Attrs)
Definition: DeclBase.h:504
clang::DeclContext::filtered_decl_iterator::filtered_decl_iterator
filtered_decl_iterator()=default
clang::Decl::getBodyRBrace
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
Definition: DeclBase.cpp:969
clang::DeclListNode::iterator::difference_type
ptrdiff_t difference_type
Definition: DeclBase.h:1293
clang::DeclContext::setHasExternalVisibleStorage
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context.
Definition: DeclBase.h:2515
clang::index::SymbolKind::Module
@ Module
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
clang::DeclContext::filtered_decl_iterator::operator!=
friend bool operator!=(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
Definition: DeclBase.h:2338
clang::PrettyStackTraceDecl
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Definition: DeclBase.h:1252
clang::DeclContextLookupResult::front
reference front() const
Definition: DeclBase.h:1357
clang::Decl::FOK_Undeclared
@ FOK_Undeclared
A friend of a previously-undeclared entity.
Definition: DeclBase.h:1178
clang::StoredDeclsList
An array of decls optimized for the common case of only containing one entry.
Definition: DeclContextInternals.h:33
clang::DeclContext::lookups_end
all_lookups_iterator lookups_end() const
clang::Decl::ModuleOwnershipKind::ReachableWhenImported
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
clang::DeclContext::isLookupContext
bool isLookupContext() const
Test whether the context supports looking up names.
Definition: DeclBase.h:1992
clang::DeclListNode::iterator::operator++
iterator operator++(int)
Definition: DeclBase.h:1319
clang::Decl::FromASTFile
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
Definition: DeclBase.h:331
clang::ASTDumpOutputFormat
ASTDumpOutputFormat
Used to specify the format for printing AST dump information.
Definition: ASTDumperUtils.h:21
clang::Decl::getDefiningAttr
const Attr * getDefiningAttr() const
Return this declaration's defining attribute if it has one.
Definition: DeclBase.cpp:520
ASTDumperUtils.h
llvm::cast_convert_val< ToTy, ::clang::DeclContext *, ::clang::DeclContext * >::doit
static ToTy * doit(::clang::DeclContext *Val)
Definition: DeclBase.h:2677
clang::Decl::updateOutOfDate
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
Definition: DeclBase.cpp:63
clang::DeclContext::makeDeclVisibleInContext
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Definition: DeclBase.cpp:1884
clang::DeclContext::isTransparentContext
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
Definition: DeclBase.cpp:1208
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:571
clang::DeclContext::ddiags
ddiag_range ddiags() const
Definition: DependentDiagnostic.h:175
clang::Decl::isInExportDeclContext
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
Definition: DeclBase.cpp:1016
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::DeclContextLookupResult::DeclContextLookupResult
DeclContextLookupResult()=default
clang::DeclContext::shouldUseQualifiedLookup
bool shouldUseQualifiedLookup() const
Definition: DeclBase.h:2534
clang::DeclContext::containsDecl
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
Definition: DeclBase.cpp:1476
clang::DeclContext::specific_decl_iterator::operator++
specific_decl_iterator & operator++()
Definition: DeclBase.h:2245
clang::DeclContext::filtered_decl_iterator::pointer
void pointer
Definition: DeclBase.h:2299
clang::Decl::getMostRecentDeclImpl
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: DeclBase.h:964
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:943
clang::Decl::operator=
Decl & operator=(const Decl &)=delete
clang::Decl::EnableStatistics
static void EnableStatistics()
Definition: DeclBase.cpp:174
clang::Decl::redecl_iterator::operator++
redecl_iterator operator++(int)
Definition: DeclBase.h:995
clang::DeclContext::decl_iterator
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:2139
clang::DeclListNode::iterator::operator==
bool operator==(const iterator &X) const
Definition: DeclBase.h:1308
IdentifierTable.h
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:2002
clang::Decl::isModulePrivate
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:625
clang::Decl::redecl_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:977
clang::DeclContext::isStdNamespace
bool isStdNamespace() const
Definition: DeclBase.cpp:1158
clang::DeclContext::specific_decl_iterator::operator==
friend bool operator==(const specific_decl_iterator &x, const specific_decl_iterator &y)
Definition: DeclBase.h:2257
clang::DeclContext::filtered_decl_iterator::operator==
friend bool operator==(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
Definition: DeclBase.h:2333
clang::DeclContext::noload_lookups
lookups_range noload_lookups(bool PreserveInternalState) const
Definition: DeclLookups.h:89
clang::DeclContext::containsDeclAndLoad
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
Definition: DeclBase.cpp:1481
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:71
clang::DeclListNode::Decls
llvm::PointerUnion< NamedDecl *, DeclListNode * > Decls
Definition: DeclBase.h:1285
clang::Decl::redecl_iterator
Iterates through all the redeclarations of the same decl.
Definition: DeclBase.h:968
clang::DeclContext::ddiag_range
llvm::iterator_range< DeclContext::ddiag_iterator > ddiag_range
Definition: DeclBase.h:2470
clang::Decl::setVisibleDespiteOwningModule
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
Definition: DeclBase.h:835
clang::DeclContext::isNamespace
bool isNamespace() const
Definition: DeclBase.h:2011
clang::Decl::getNonTransparentDeclContext
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
Definition: DeclBase.cpp:1051
clang::Decl::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: DeclBase.h:1014
clang::DeclContextLookupResult::find_first
T * find_first() const
Definition: DeclBase.h:1363
clang::cast_convert_decl_context< ToTy, true >::doit
static ToTy * doit(DeclContext *Val)
Definition: DeclBase.h:2634
clang::Decl::setNonMemberOperator
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
Definition: DeclBase.h:1194
clang::DeclContext::getOuterLexicalRecordContext
const RecordDecl * getOuterLexicalRecordContext() const
Definition: DeclBase.h:2100
clang::DeclContext::decl_iterator::operator!=
friend bool operator!=(decl_iterator x, decl_iterator y)
Definition: DeclBase.h:2173
clang::DeclContext::getLookupParent
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
Definition: DeclBase.cpp:1125
clang::Decl::dump
void dump() const
Definition: ASTDumper.cpp:206
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:85
clang::DeclContext::isRecord
bool isRecord() const
Definition: DeclBase.h:2006
clang::Decl::getMostRecentDecl
const Decl * getMostRecentDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1045
clang::Decl::setImplicit
void setImplicit(bool I=true)
Definition: DeclBase.h:577
clang::Decl::getCanonicalDecl
const Decl * getCanonicalDecl() const
Definition: DeclBase.h:944
clang::DeclContext::isDeclInLexicalTraversal
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
Definition: DeclBase.h:2523
x
IRgen optimization opportunities The common pattern of short x
Definition: README.txt:7
clang::Decl::castToDeclContext
static DeclContext * castToDeclContext(const Decl *)
Definition: DeclBase.cpp:950
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
clang::Decl::getOwningModule
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:808
clang::Decl::IDNS_Member
@ IDNS_Member
Members, declared with object declarations within tag definitions.
Definition: DeclBase.h:133
clang::Decl::canBeWeakImported
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
Definition: DeclBase.cpp:702
clang::Decl::dropAttr
void dropAttr()
Definition: DeclBase.h:531
clang::Decl::IDNS_OMPMapper
@ IDNS_OMPMapper
This declaration is an OpenMP user defined mapper.
Definition: DeclBase.h:178
clang::Decl::IDNS_Ordinary
@ IDNS_Ordinary
Ordinary names.
Definition: DeclBase.h:141
clang::Decl::hasDefiningAttr
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
Definition: DeclBase.cpp:515
clang::DeclContext::filtered_decl_iterator::operator*
value_type operator*() const
Definition: DeclBase.h:2318
clang::Decl::getTranslationUnitDecl
const TranslationUnitDecl * getTranslationUnitDecl() const
Definition: DeclBase.h:469
clang::Decl::ModuleOwnershipKind::Visible
@ Visible
This declaration has an owning module, but is globally visible (typically because its owning module i...
clang::Decl::castFromDeclContext
static Decl * castFromDeclContext(const DeclContext *)
Definition: DeclBase.cpp:931
clang::Decl::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl()
Definition: DeclBase.cpp:413
clang::Decl::redecl_iterator::redecl_iterator
redecl_iterator(Decl *C)
Definition: DeclBase.h:981
clang::Decl::redecl_iterator::operator->
value_type operator->() const
Definition: DeclBase.h:984
clang::ObjCMethodFamilyBitWidth
@ ObjCMethodFamilyBitWidth
Definition: IdentifierTable.h:728
llvm::cast_convert_val< const ::clang::DeclContext, FromTy *, FromTy * >::doit
static const ::clang::DeclContext * doit(const FromTy *Val)
Definition: DeclBase.h:2706
clang::Decl::IDNS_Namespace
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
Definition: DeclBase.h:137
clang::AccessSpecifier
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:111
clang::DeclContext::filtered_decl_iterator::operator++
filtered_decl_iterator & operator++()
Definition: DeclBase.h:2321
clang::Decl::getSourceRange
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:420
clang::DeclContext::specific_decl_iterator::value_type
SpecificDecl * value_type
Definition: DeclBase.h:2217
clang::Decl::isInIdentifierNamespace
bool isInIdentifierNamespace(unsigned NS) const
Definition: DeclBase.h:858
clang::DeclContext::DeclContext
DeclContext(Decl::Kind K)
Definition: DeclBase.cpp:1089
clang::Decl::setLocation
void setLocation(SourceLocation L)
Definition: DeclBase.h:433
clang::Decl::OBJC_TQ_In
@ OBJC_TQ_In
Definition: DeclBase.h:197
SourceLocation.h
clang::DeclContext::getRedeclContext
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1829
clang::DeclContext::hasValidDeclKind
bool hasValidDeclKind() const
Definition: DeclBase.cpp:155
clang::Decl::CacheValidAndLinkage
unsigned CacheValidAndLinkage
If 0, we have not computed the linkage of this declaration.
Definition: DeclBase.h:338
clang::Decl::isReachable
bool isReachable() const
Definition: DeclBase.h:828
P
StringRef P
Definition: ASTMatchersInternal.cpp:564
clang::DeclContext::DeclContextBits
DeclContextBitfields DeclContextBits
Definition: DeclBase.h:1859
clang::Decl::getPreviousDecl
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:1026
clang::Decl::getFriendObjectKind
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition: DeclBase.h:1185
clang::Decl::hasAttrs
bool hasAttrs() const
Definition: DeclBase.h:502
clang::DeclContext::getPrimaryContext
const DeclContext * getPrimaryContext() const
Definition: DeclBase.h:2080
clang::Decl::isFromASTFile
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:751
clang::DeclContext::LinkageSpecDeclBits
LinkageSpecDeclBitfields LinkageSpecDeclBits
Definition: DeclBase.h:1868
clang::DeclContext::lookup_iterator
lookup_result::iterator lookup_iterator
Definition: DeclBase.h:2387
false
#define false
Definition: stdbool.h:22
clang::Language
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
clang::DeclContext::getDeclKindName
const char * getDeclKindName() const
Definition: DeclBase.cpp:164
clang::DeclContext::filtered_decl_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2302
clang::Decl::IDNS_Label
@ IDNS_Label
Labels, declared with 'x:' and referenced with 'goto x'.
Definition: DeclBase.h:114
clang::DeclContext::decl_range
llvm::iterator_range< decl_iterator > decl_range
Definition: DeclBase.h:2178
clang::DeclContext::udir_iterator::operator*
UsingDirectiveDecl * operator*() const
Definition: DeclBase.cpp:1975
clang::DeclContext::addDecl
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1607
clang::Decl::Access
unsigned Access
Access - Used by C++ decls for the access specifier.
Definition: DeclBase.h:328
clang::Decl::getDescribedTemplate
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
Definition: DeclBase.cpp:239
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1927
clang::Decl::IDNS_OMPReduction
@ IDNS_OMPReduction
This declaration is an OpenMP user defined reduction construction.
Definition: DeclBase.h:175
clang::DeclContext::~DeclContext
~DeclContext()
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:407
clang::DeclListNode::iterator::reference
value_type reference
Definition: DeclBase.h:1296
clang::DeclContext::dumpLookups
void dumpLookups() const
Definition: ASTDumper.cpp:256
Begin
SourceLocation Begin
Definition: USRLocFinder.cpp:165
llvm::ArrayRef
Definition: LLVM.h:34
clang::cast_convert_decl_context
Definition: DeclBase.h:2617
clang::Decl::attr_begin
attr_iterator attr_begin() const
Definition: DeclBase.h:523
clang::Decl::Decl
Decl(Kind DK, DeclContext *DC, SourceLocation L)
Definition: DeclBase.h:382
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::Decl::isTemplated
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
Definition: DeclBase.cpp:262
clang::Decl::getTemplateDepth
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
Definition: DeclBase.cpp:274
clang::DeclContext::decl_iterator::operator++
decl_iterator operator++(int)
Definition: DeclBase.h:2163
clang::DeclContext::specific_decl_iterator::operator!=
friend bool operator!=(const specific_decl_iterator &x, const specific_decl_iterator &y)
Definition: DeclBase.h:2262
clang::Decl::redecl_iterator::redecl_iterator
redecl_iterator()=default
clang::Decl::IDNS_ObjCProtocol
@ IDNS_ObjCProtocol
Objective C @protocol.
Definition: DeclBase.h:144
clang::DeclContext::getOuterLexicalRecordContext
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
Definition: DeclBase.cpp:1855
clang::DeclListNode::iterator::operator->
void operator->() const
Definition: DeclBase.h:1307
clang::Decl::IDNS_NonMemberOperator
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
Definition: DeclBase.h:165
clang::Decl::FOK_Declared
@ FOK_Declared
A friend of a previously-declared entity.
Definition: DeclBase.h:1177
LLVM.h
clang::DeclContext::isExternCXXContext
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Definition: DeclBase.cpp:1240
clang::DeclContextLookupResult::end
iterator end()
Definition: DeclBase.h:1349
clang::Decl::IdentifierNamespace
unsigned IdentifierNamespace
IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
Definition: DeclBase.h:334
clang::Decl::getExternalSourceSymbolAttr
ExternalSourceSymbolAttr * getExternalSourceSymbolAttr() const
Looks on this and related declarations for an applicable external source symbol attribute.
Definition: DeclBase.cpp:494
clang::Decl::redecl_iterator::operator!=
friend bool operator!=(redecl_iterator x, redecl_iterator y)
Definition: DeclBase.h:1005
clang::Decl::attrs
attr_range attrs() const
Definition: DeclBase.h:519
clang::DeclContext::specific_decl_iterator::operator*
value_type operator*() const
Definition: DeclBase.h:2240
clang::Decl::Decl
Decl(Kind DK, EmptyShell Empty)
Definition: DeclBase.h:392
clang::Decl::getPreviousDecl
const Decl * getPreviousDecl() const
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:1030
clang::Decl::setCachedLinkage
void setCachedLinkage(Linkage L) const
Definition: DeclBase.h:410
clang::cast_convert_decl_context::doit
static ToTy * doit(DeclContext *Val)
Definition: DeclBase.h:2622
clang::DeclContext::Encloses
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Definition: DeclBase.cpp:1244
clang::Decl::attr_iterator
AttrVec::const_iterator attr_iterator
Definition: DeclBase.h:516
clang::DeclContext::filtered_decl_iterator
Iterates over a filtered subrange of declarations stored in a DeclContext.
Definition: DeclBase.h:2278
clang::DeclContext::isFileContext
bool isFileContext() const
Definition: DeclBase.h:1997
clang::DeclContext::noload_lookup
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Definition: DeclBase.cpp:1758
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::DeclListNode::iterator::value_type
NamedDecl * value_type
Definition: DeclBase.h:1294
clang::DeclContext::noload_lookups_end
all_lookups_iterator noload_lookups_end() const
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:82
clang::Decl::setObjectOfFriendDecl
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
Definition: DeclBase.h:1145
clang::DeclContext::decl_iterator::difference_type
std::ptrdiff_t difference_type
Definition: DeclBase.h:2148
clang::DeclContext::getInnermostBlockDecl
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
Definition: DeclBase.cpp:1141
clang::Decl::setModulePrivate
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:661
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:359
clang::DeclContext::collectAllContexts
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context.
Definition: DeclBase.cpp:1350
clang::Decl::getBody
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:1052
clang::DeclListNode::iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:1297
llvm::isa_impl< To, ::clang::DeclContext >::doit
static bool doit(const ::clang::DeclContext &Val)
Definition: DeclBase.h:2646
clang::Decl::hasOwningModule
bool hasOwningModule() const
Is this declaration owned by some module?
Definition: DeclBase.h:803
clang::DeclContext::ddiag_iterator
An iterator over the dependent diagnostics in a dependent context.
Definition: DependentDiagnostic.h:125
DeclarationName.h
clang::DeclContext::setMustBuildLookupTable
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
Definition: DeclBase.h:2482
clang::Decl::isUnconditionallyVisible
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition: DeclBase.h:824
clang::PrettyStackTraceDecl::print
void print(raw_ostream &OS) const override
Definition: DeclBase.cpp:309
clang::Decl::setOwningModuleID
void setOwningModuleID(unsigned ID)
Set the owning module ID.
Definition: DeclBase.h:679
clang::DeclContext::classof
static bool classof(const DeclContext *D)
Definition: DeclBase.h:2539
clang::Decl::getNonTransparentDeclContext
const DeclContext * getNonTransparentDeclContext() const
Definition: DeclBase.h:454
clang::DependentDiagnostic
A dependently-generated diagnostic.
Definition: DependentDiagnostic.h:36
clang::Decl::~Decl
virtual ~Decl()
clang::AR_NotYetIntroduced
@ AR_NotYetIntroduced
Definition: DeclBase.h:71
clang::Decl::isParameterPack
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:220
clang::Builtin::ID
ID
Definition: Builtins.h:64
clang::DeclListNode
A list storing NamedDecls in the lookup tables.
Definition: DeclBase.h:1281
clang::AR_Unavailable
@ AR_Unavailable
Definition: DeclBase.h:73
clang
Definition: CalledOnceCheck.h:17
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1693
clang::Decl::getDeclContext
const DeclContext * getDeclContext() const
Definition: DeclBase.h:446
hlsl::int64_t
long int64_t
Definition: hlsl_basic_types.h:26
clang::Decl::OBJC_TQ_CSNullability
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Definition: DeclBase.h:207
clang::DeclContext::buildLookup
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
Definition: DeclBase.cpp:1630
clang::Decl::isTagIdentifierNamespace
static bool isTagIdentifierNamespace(unsigned NS)
Definition: DeclBase.h:868
clang::DeclContext::filtered_decl_iterator::value_type
SpecificDecl * value_type
Definition: DeclBase.h:2295
clang::DeclContext::filtered_decl_iterator::operator->
value_type operator->() const
Definition: DeclBase.h:2319
clang::PrettyStackTraceDecl::PrettyStackTraceDecl
PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg)
Definition: DeclBase.h:1259
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:72
ptrdiff_t
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
Definition: opencl-c-base.h:145
clang::AvailabilityResult
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:69
clang::Decl::print
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Definition: DeclPrinter.cpp:126
clang::Decl::getAccessUnsafe
AccessSpecifier getAccessUnsafe() const
Retrieve the access specifier for this declaration, even though it may not yet have been properly set...
Definition: DeclBase.h:498
clang::DeclContext::noload_decls_begin
decl_iterator noload_decls_begin() const
Definition: DeclBase.h:2193
clang::Decl::ModuleOwnershipKind::Unowned
@ Unowned
This declaration is not owned by a module.
clang::DeclContext::CXXConstructorDeclBits
CXXConstructorDeclBitfields CXXConstructorDeclBits
Definition: DeclBase.h:1865
clang::ADOF_Default
@ ADOF_Default
Definition: ASTDumperUtils.h:22
clang::Decl::isFirstDecl
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: DeclBase.h:1035
clang::Decl::OBJC_TQ_Oneway
@ OBJC_TQ_Oneway
Definition: DeclBase.h:202
clang::ASTNodeImporter
Definition: ASTImporter.cpp:178
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:40
clang::DeclContext::udir_range
llvm::iterator_range< udir_iterator > udir_range
Definition: DeclBase.h:2463
clang::DeclContext::lookups_begin
all_lookups_iterator lookups_begin() const
Iterators over all possible lookups within this context.
clang::DeclContext::isDependentContext
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1174
clang::DeclListNode::iterator::operator++
iterator & operator++()
Definition: DeclBase.h:1310
unsigned
clang::Decl::specific_attr_begin
specific_attr_iterator< T > specific_attr_begin() const
Definition: DeclBase.h:547
clang::Decl::DeclContext
friend class DeclContext
Definition: DeclBase.h:249
llvm::PointerLikeTypeTraits
Definition: DeclGroup.h:139
clang::Decl::setFromASTFile
void setFromASTFile()
Set the FromASTFile flag.
Definition: DeclBase.h:673
udir_iterator_base
clang::Decl::getAttrs
AttrVec & getAttrs()
Definition: DeclBase.h:508
clang::Decl::hasLocalOwningModuleStorage
bool hasLocalOwningModuleStorage() const
Definition: DeclBase.cpp:119
clang::Decl::CXXClassMemberWrapper
friend class CXXClassMemberWrapper
Definition: DeclBase.h:321
clang::Decl::isDefinedOutsideFunctionOrMethod
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
Definition: DeclBase.h:914
clang::cast_convert_decl_context::doit
static const ToTy * doit(const DeclContext *Val)
Definition: DeclBase.h:2618
clang::DeclContextLookupResult
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1334
clang::DeclContext::getLookupPtr
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
Definition: DeclBase.h:2490
clang::Decl::getOwningModuleID
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
Definition: DeclBase.h:763
clang::Decl::getLocalOwningModule
Module * getLocalOwningModule() const
Get the local owning module, if known.
Definition: DeclBase.h:787
clang::Decl::EmptyShell
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:99
Parent
NodeId Parent
Definition: ASTDiff.cpp:191
clang::DeclContext::isExternCContext
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Definition: DeclBase.cpp:1225
clang::Decl::getDescribedTemplateParams
const TemplateParameterList * getDescribedTemplateParams() const
If this is a declaration that describes some template or partial specialization, this returns the cor...
Definition: DeclBase.cpp:252
clang::Decl::setInvalidDecl
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:132
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::DeclContext::EnumDeclBits
EnumDeclBitfields EnumDeclBits
Definition: DeclBase.h:1861
clang::Decl::OBJC_TQ_Inout
@ OBJC_TQ_Inout
Definition: DeclBase.h:198
true
#define true
Definition: stdbool.h:21
clang::Decl::redecl_iterator::operator==
friend bool operator==(redecl_iterator x, redecl_iterator y)
Definition: DeclBase.h:1001
clang::DeclContext::filtered_decl_iterator::filtered_decl_iterator
filtered_decl_iterator(DeclContext::decl_iterator C)
filtered_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
Definition: DeclBase.h:2314
clang::DeclContext::LastDecl
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
Definition: DeclBase.h:1903
clang::ASTDeclReader
Definition: ASTReaderDecl.cpp:81
SM
#define SM(sm)
Definition: Cuda.cpp:78
clang::Decl::attr_range
llvm::iterator_range< attr_iterator > attr_range
Definition: DeclBase.h:517
clang::Decl::getVersionIntroduced
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
Definition: DeclBase.cpp:688
clang::LinkageComputer
Definition: Linkage.h:74
clang::DeclContext::udir_iterator::udir_iterator
udir_iterator(lookup_iterator I)
Definition: DeclBase.h:2458
clang::Decl::isInvisibleOutsideTheOwningModule
bool isInvisibleOutsideTheOwningModule() const
Definition: DeclBase.h:643
clang::DeclContext::getEnclosingNamespaceContext
const DeclContext * getEnclosingNamespaceContext() const
Definition: DeclBase.h:2094
clang::Decl::dropAttrs
void dropAttrs()
Definition: DeclBase.cpp:896
clang::DeclContext::RecordDeclBits
RecordDeclBitfields RecordDeclBits
Definition: DeclBase.h:1862
clang::ExternalASTSource
Abstract interface for external sources of AST nodes.
Definition: ExternalASTSource.h:60
clang::DeclContext::getLexicalParent
const DeclContext * getLexicalParent() const
Definition: DeclBase.h:1946
clang::Decl::setLocalExternDecl
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
Definition: DeclBase.h:1116
clang::DeclContext::isFunctionOrMethod
bool isFunctionOrMethod() const
Definition: DeclBase.h:1979
clang::DeclListNode::iterator::iterator
iterator()=default
clang::Decl::isInLocalScopeForInstantiation
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
Definition: DeclBase.cpp:376
clang::ASTDeclWriter
Definition: ASTWriterDecl.cpp:35
llvm::PointerLikeTypeTraits<::clang::NamedDecl * >::getAsVoidPointer
static void * getAsVoidPointer(::clang::NamedDecl *P)
Definition: DeclBase.h:1271
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
clang::Decl::getMaxAlignment
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
Definition: DeclBase.cpp:442
clang::Decl::getID
int64_t getID() const
Definition: DeclBase.cpp:1028
clang::Decl::setReferenced
void setReferenced(bool R=true)
Definition: DeclBase.h:606
clang::Decl::addAttr
void addAttr(Attr *A)
Definition: DeclBase.cpp:903
clang::Decl::IDNS_Tag
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Definition: DeclBase.h:122
clang::Decl::getPreviousDeclImpl
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition: DeclBase.h:960
clang::RISCV::Invalid
@ Invalid
Definition: RISCVVIntrinsicUtils.h:213
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:949
clang::DeclContextLookupResult::empty
bool empty() const
Definition: DeclBase.h:1355
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1917
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3996
clang::DeclContext::specific_decl_iterator::difference_type
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
Definition: DeclBase.h:2223
clang::DeclContext::Equals
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
Definition: DeclBase.h:2051
clang::Decl::IDNS_LocalExtern
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
Definition: DeclBase.h:172
clang::Decl::classofKind
static bool classofKind(Kind K)
Definition: DeclBase.h:1201
clang::Decl::setLocalOwningModule
void setLocalOwningModule(Module *M)
Definition: DeclBase.h:795
clang::DeclContext::FunctionDeclBits
FunctionDeclBitfields FunctionDeclBits
Definition: DeclBase.h:1864
clang::DeclContext::decl_iterator::decl_iterator
decl_iterator(Decl *C)
Definition: DeclBase.h:2151
clang::DeclContext::getRedeclContext
const DeclContext * getRedeclContext() const
Definition: DeclBase.h:2088
clang::Decl::getParentFunctionOrMethod
DeclContext * getParentFunctionOrMethod(bool LexicalParent=false)
Definition: DeclBase.h:936
clang::Decl::OBJC_TQ_None
@ OBJC_TQ_None
Definition: DeclBase.h:196
clang::Decl::dumpColor
void dumpColor() const
Definition: ASTDumper.cpp:225
clang::specific_attr_iterator
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Definition: AttrIterator.h:33
llvm::cast_convert_val< const ::clang::DeclContext, FromTy, FromTy >::doit
static const ::clang::DeclContext & doit(const FromTy &Val)
Definition: DeclBase.h:2699
clang::Decl::getMostRecentDecl
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1041
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1240
clang::Decl::IDNS_OrdinaryFriend
@ IDNS_OrdinaryFriend
This declaration is a friend function.
Definition: DeclBase.h:149
clang::Decl::getDeclKindName
const char * getDeclKindName() const
Definition: DeclBase.cpp:123
clang::DeclContext::TagDeclBits
TagDeclBitfields TagDeclBits
Definition: DeclBase.h:1860
clang::Decl::isInAnonymousNamespace
bool isInAnonymousNamespace() const
Definition: DeclBase.cpp:393
clang::DeclContextLookupResult::iterator
DeclListNode::iterator iterator
Definition: DeclBase.h:1344
clang::DeclContext::getNonTransparentContext
const DeclContext * getNonTransparentContext() const
Definition: DeclBase.h:2069
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:441
clang::Decl::redecls_end
redecl_iterator redecls_end() const
Definition: DeclBase.h:1022
clang::DeclContext::decls_begin
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1463