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