Clang Project

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