diff options
Diffstat (limited to 'include/clang/AST/DeclBase.h')
-rw-r--r-- | include/clang/AST/DeclBase.h | 241 |
1 files changed, 129 insertions, 112 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index f93c9f0b9aaa1..f99bd627877c5 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -19,7 +19,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "clang/Basic/VersionTuple.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" @@ -28,6 +27,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/VersionTuple.h" #include <algorithm> #include <cassert> #include <cstddef> @@ -67,7 +67,7 @@ class TemplateDecl; class TranslationUnitDecl; class UsingDirectiveDecl; -/// \brief Captures the result of checking the availability of a +/// Captures the result of checking the availability of a /// declaration. enum AvailabilityResult { AR_Available = 0, @@ -83,9 +83,9 @@ enum AvailabilityResult { /// (and its subclasses) in its Decl::operator new(). Proper alignment /// of all subclasses (not requiring more than the alignment of Decl) is /// asserted in DeclBase.cpp. -class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) Decl { +class alignas(8) Decl { public: - /// \brief Lists the kind of concrete classes of Decl. + /// Lists the kind of concrete classes of Decl. enum Kind { #define DECL(DERIVED, BASE) DERIVED, #define ABSTRACT_DECL(DECL) @@ -96,7 +96,7 @@ public: #include "clang/AST/DeclNodes.inc" }; - /// \brief A placeholder type used to construct an empty shell of a + /// A placeholder type used to construct an empty shell of a /// decl-derived type that will be filled in later (e.g., by some /// deserialization method). struct EmptyShell {}; @@ -231,7 +231,7 @@ public: }; protected: - /// \brief The next declaration within the same lexical + /// The next declaration within the same lexical /// DeclContext. These pointers form the linked list that is /// traversed via DeclContext's decls_begin()/decls_end(). /// @@ -288,27 +288,28 @@ private: /// the implementation rather than explicitly written by the user. unsigned Implicit : 1; - /// \brief Whether this declaration was "used", meaning that a definition is + /// Whether this declaration was "used", meaning that a definition is /// required. unsigned Used : 1; - /// \brief Whether this declaration was "referenced". + /// Whether this declaration was "referenced". /// The difference with 'Used' is whether the reference appears in a /// evaluated context or not, e.g. functions used in uninstantiated templates /// are regarded as "referenced" but not "used". unsigned Referenced : 1; - /// \brief Whether this declaration is a top-level declaration (function, + /// Whether this declaration is a top-level declaration (function, /// global variable, etc.) that is lexically inside an objc container /// definition. unsigned TopLevelDeclInObjCContainer : 1; - /// \brief Whether statistic collection is enabled. + /// Whether statistic collection is enabled. static bool StatisticsEnabled; protected: friend class ASTDeclReader; friend class ASTDeclWriter; + friend class ASTNodeImporter; friend class ASTReader; friend class CXXClassMemberWrapper; friend class LinkageComputer; @@ -318,17 +319,17 @@ protected: // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum unsigned Access : 2; - /// \brief Whether this declaration was loaded from an AST file. + /// Whether this declaration was loaded from an AST file. unsigned FromASTFile : 1; /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. unsigned IdentifierNamespace : 13; - /// \brief If 0, we have not computed the linkage of this declaration. + /// If 0, we have not computed the linkage of this declaration. /// Otherwise, it is the linkage + 1. mutable unsigned CacheValidAndLinkage : 3; - /// \brief Allocate memory for a deserialized declaration. + /// Allocate memory for a deserialized declaration. /// /// This routine must be used to allocate memory for any declaration that is /// deserialized from a module file. @@ -340,7 +341,7 @@ protected: void *operator new(std::size_t Size, const ASTContext &Ctx, unsigned ID, std::size_t Extra = 0); - /// \brief Allocate memory for a non-deserialized declaration. + /// Allocate memory for a non-deserialized declaration. void *operator new(std::size_t Size, const ASTContext &Ctx, DeclContext *Parent, std::size_t Extra = 0); @@ -384,7 +385,7 @@ protected: virtual ~Decl(); - /// \brief Update a potentially out-of-date declaration. + /// Update a potentially out-of-date declaration. void updateOutOfDate(IdentifierInfo &II) const; Linkage getCachedLinkage() const { @@ -400,7 +401,7 @@ protected: } public: - /// \brief Source range that this declaration covers. + /// Source range that this declaration covers. virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getLocation()); } @@ -462,7 +463,7 @@ public: return AccessSpecifier(Access); } - /// \brief Retrieve the access specifier for this declaration, even though + /// Retrieve the access specifier for this declaration, even though /// it may not yet have been properly set. AccessSpecifier getAccessUnsafe() const { return AccessSpecifier(Access); @@ -551,7 +552,7 @@ public: bool isImplicit() const { return Implicit; } void setImplicit(bool I = true) { Implicit = I; } - /// \brief Whether *any* (re-)declaration of the entity was used, meaning that + /// Whether *any* (re-)declaration of the entity was used, meaning that /// a definition is required. /// /// \param CheckUsedAttr When true, also consider the "used" attribute @@ -559,28 +560,28 @@ public: /// whether the function is used. bool isUsed(bool CheckUsedAttr = true) const; - /// \brief Set whether the declaration is used, in the sense of odr-use. + /// Set whether the declaration is used, in the sense of odr-use. /// /// This should only be used immediately after creating a declaration. /// It intentionally doesn't notify any listeners. void setIsUsed() { getCanonicalDecl()->Used = true; } - /// \brief Mark the declaration used, in the sense of odr-use. + /// Mark the declaration used, in the sense of odr-use. /// /// This notifies any mutation listeners in addition to setting a bit /// indicating the declaration is used. void markUsed(ASTContext &C); - /// \brief Whether any declaration of this entity was referenced. + /// Whether any declaration of this entity was referenced. bool isReferenced() const; - /// \brief Whether this declaration was referenced. This should not be relied + /// Whether this declaration was referenced. This should not be relied /// upon for anything other than debugging. bool isThisDeclarationReferenced() const { return Referenced; } void setReferenced(bool R = true) { Referenced = R; } - /// \brief Whether this declaration is a top-level declaration (function, + /// Whether this declaration is a top-level declaration (function, /// global variable, etc.) that is lexically inside an objc container /// definition. bool isTopLevelDeclInObjCContainer() const { @@ -591,17 +592,17 @@ public: TopLevelDeclInObjCContainer = V; } - /// \brief Looks on this and related declarations for an applicable + /// Looks on this and related declarations for an applicable /// external source symbol attribute. ExternalSourceSymbolAttr *getExternalSourceSymbolAttr() const; - /// \brief Whether this declaration was marked as being private to the + /// Whether this declaration was marked as being private to the /// module in which it was defined. bool isModulePrivate() const { return getModuleOwnershipKind() == ModuleOwnershipKind::ModulePrivate; } - /// \brief Whether this declaration is exported (by virtue of being lexically + /// Whether this declaration is exported (by virtue of being lexically /// within an ExportDecl or by being a NamespaceDecl). bool isExported() const; @@ -613,7 +614,7 @@ public: const Attr *getDefiningAttr() const; protected: - /// \brief Specify that this declaration was marked as being private + /// Specify that this declaration was marked as being private /// to the module in which it was defined. void setModulePrivate() { // The module-private specifier has no effect on unowned declarations. @@ -623,14 +624,14 @@ protected: setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate); } - /// \brief Set the owning module ID. + /// Set the owning module ID. void setOwningModuleID(unsigned ID) { assert(isFromASTFile() && "Only works on a deserialized declaration"); *((unsigned*)this - 2) = ID; } public: - /// \brief Determine the availability of the given declaration. + /// Determine the availability of the given declaration. /// /// This routine will determine the most restrictive availability of /// the given declaration (e.g., preferring 'unavailable' to @@ -643,11 +644,16 @@ public: /// /// \param EnclosingVersion The version to compare with. If empty, assume the /// deployment target version. + /// + /// \param RealizedPlatform If non-NULL and the availability result is found + /// in an available attribute it will set to the platform which is written in + /// the available attribute. AvailabilityResult getAvailability(std::string *Message = nullptr, - VersionTuple EnclosingVersion = VersionTuple()) const; + VersionTuple EnclosingVersion = VersionTuple(), + StringRef *RealizedPlatform = nullptr) const; - /// \brief Retrieve the version of the target platform in which this + /// Retrieve the version of the target platform in which this /// declaration was introduced. /// /// \returns An empty version tuple if this declaration has no 'introduced' @@ -655,7 +661,7 @@ public: /// attribute otherwise. VersionTuple getVersionIntroduced() const; - /// \brief Determine whether this declaration is marked 'deprecated'. + /// Determine whether this declaration is marked 'deprecated'. /// /// \param Message If non-NULL and the declaration is deprecated, /// this will be set to the message describing why the declaration @@ -664,7 +670,7 @@ public: return getAvailability(Message) == AR_Deprecated; } - /// \brief Determine whether this declaration is marked 'unavailable'. + /// Determine whether this declaration is marked 'unavailable'. /// /// \param Message If non-NULL and the declaration is unavailable, /// this will be set to the message describing why the declaration @@ -673,7 +679,7 @@ public: return getAvailability(Message) == AR_Unavailable; } - /// \brief Determine whether this is a weak-imported symbol. + /// Determine whether this is a weak-imported symbol. /// /// Weak-imported symbols are typically marked with the /// 'weak_import' attribute, but may also be marked with an @@ -681,7 +687,7 @@ public: /// the introduction of this feature. bool isWeakImported() const; - /// \brief Determines whether this symbol can be weak-imported, + /// Determines whether this symbol can be weak-imported, /// e.g., whether it would be well-formed to add the weak_import /// attribute. /// @@ -689,11 +695,11 @@ public: /// declaration cannot be weak-imported because it has a definition. bool canBeWeakImported(bool &IsDefinition) const; - /// \brief Determine whether this declaration came from an AST file (such as + /// Determine whether this declaration came from an AST file (such as /// a precompiled header or module) rather than having been parsed. bool isFromASTFile() const { return FromASTFile; } - /// \brief Retrieve the global declaration ID associated with this + /// Retrieve the global declaration ID associated with this /// declaration, which specifies where this Decl was loaded from. unsigned getGlobalID() const { if (isFromASTFile()) @@ -701,7 +707,7 @@ public: return 0; } - /// \brief Retrieve the global ID of the module that owns this particular + /// Retrieve the global ID of the module that owns this particular /// declaration. unsigned getOwningModuleID() const { if (isFromASTFile()) @@ -716,7 +722,7 @@ protected: bool hasLocalOwningModuleStorage() const; public: - /// \brief Get the imported owning module, if this decl is from an imported + /// Get the imported owning module, if this decl is from an imported /// (non-local) module. Module *getImportedOwningModule() const { if (!isFromASTFile() || !hasOwningModule()) @@ -725,7 +731,7 @@ public: return getOwningModuleSlow(); } - /// \brief Get the local owning module, if known. Returns nullptr if owner is + /// Get the local owning module, if known. Returns nullptr if owner is /// not yet known or declaration is not from a module. Module *getLocalOwningModule() const { if (isFromASTFile() || !hasOwningModule()) @@ -759,7 +765,7 @@ public: /// all declarations in a global module fragment are unowned. Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const; - /// \brief Determine whether this declaration might be hidden from name + /// Determine whether this declaration might be hidden from name /// lookup. Note that the declaration might be visible even if this returns /// \c false, if the owning module is visible within the query context. // FIXME: Rename this to make it clearer what it does. @@ -774,12 +780,12 @@ public: setModuleOwnershipKind(ModuleOwnershipKind::Visible); } - /// \brief Get the kind of module ownership for this declaration. + /// Get the kind of module ownership for this declaration. ModuleOwnershipKind getModuleOwnershipKind() const { return NextInContextAndBits.getInt(); } - /// \brief Set whether this declaration is hidden from name lookup. + /// Set whether this declaration is hidden from name lookup. void setModuleOwnershipKind(ModuleOwnershipKind MOK) { assert(!(getModuleOwnershipKind() == ModuleOwnershipKind::Unowned && MOK != ModuleOwnershipKind::Unowned && !isFromASTFile() && @@ -836,6 +842,10 @@ public: void setLexicalDeclContext(DeclContext *DC); + /// Determine whether this declaration is a templated entity (whether it is + // within the scope of a template parameter). + bool isTemplated() const; + /// isDefinedOutsideFunctionOrMethod - This predicate returns true if this /// scoped decl is defined outside the current function or method. This is /// roughly global variables and functions, but also handles enums (which @@ -844,7 +854,7 @@ public: return getParentFunctionOrMethod() == nullptr; } - /// \brief Returns true if this declaration lexically is inside a function. + /// Returns true if this declaration lexically is inside a function. /// It recognizes non-defining declarations as well as members of local /// classes: /// \code @@ -853,7 +863,7 @@ public: /// \endcode bool isLexicallyWithinFunctionOrMethod() const; - /// \brief If this decl is defined inside a function/method/block it returns + /// If this decl is defined inside a function/method/block it returns /// the corresponding DeclContext, otherwise it returns null. const DeclContext *getParentFunctionOrMethod() const; DeclContext *getParentFunctionOrMethod() { @@ -861,32 +871,32 @@ public: const_cast<const Decl*>(this)->getParentFunctionOrMethod()); } - /// \brief Retrieves the "canonical" declaration of the given declaration. + /// Retrieves the "canonical" declaration of the given declaration. virtual Decl *getCanonicalDecl() { return this; } const Decl *getCanonicalDecl() const { return const_cast<Decl*>(this)->getCanonicalDecl(); } - /// \brief Whether this particular Decl is a canonical one. + /// Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } protected: - /// \brief Returns the next redeclaration or itself if this is the only decl. + /// Returns the next redeclaration or itself if this is the only decl. /// /// Decl subclasses that can be redeclared should override this method so that /// Decl::redecl_iterator can iterate over them. virtual Decl *getNextRedeclarationImpl() { return this; } - /// \brief Implementation of getPreviousDecl(), to be overridden by any + /// Implementation of getPreviousDecl(), to be overridden by any /// subclass that has a redeclaration chain. virtual Decl *getPreviousDeclImpl() { return nullptr; } - /// \brief Implementation of getMostRecentDecl(), to be overridden by any + /// Implementation of getMostRecentDecl(), to be overridden by any /// subclass that has a redeclaration chain. virtual Decl *getMostRecentDeclImpl() { return this; } public: - /// \brief Iterates through all the redeclarations of the same decl. + /// Iterates through all the redeclarations of the same decl. class redecl_iterator { /// Current - The current declaration. Decl *Current = nullptr; @@ -931,7 +941,7 @@ public: using redecl_range = llvm::iterator_range<redecl_iterator>; - /// \brief Returns an iterator range for all the redeclarations of the same + /// Returns an iterator range for all the redeclarations of the same /// decl. It will iterate at least once (when this decl is the only one). redecl_range redecls() const { return redecl_range(redecls_begin(), redecls_end()); @@ -943,26 +953,26 @@ public: redecl_iterator redecls_end() const { return redecl_iterator(); } - /// \brief Retrieve the previous declaration that declares the same entity + /// Retrieve the previous declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. Decl *getPreviousDecl() { return getPreviousDeclImpl(); } - /// \brief Retrieve the most recent declaration that declares the same entity + /// Retrieve the most recent declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. const Decl *getPreviousDecl() const { return const_cast<Decl *>(this)->getPreviousDeclImpl(); } - /// \brief True if this is the first declaration in its redeclaration chain. + /// True if this is the first declaration in its redeclaration chain. bool isFirstDecl() const { return getPreviousDecl() == nullptr; } - /// \brief Retrieve the most recent declaration that declares the same entity + /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). Decl *getMostRecentDecl() { return getMostRecentDeclImpl(); } - /// \brief Retrieve the most recent declaration that declares the same entity + /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). const Decl *getMostRecentDecl() const { return const_cast<Decl *>(this)->getMostRecentDeclImpl(); @@ -973,7 +983,7 @@ public: /// top-level Stmt* of that body. Otherwise this method returns null. virtual Stmt* getBody() const { return nullptr; } - /// \brief Returns true if this \c Decl represents a declaration for a body of + /// Returns true if this \c Decl represents a declaration for a body of /// code, such as a function or method definition. /// Note that \c hasBody can also return true if any redeclaration of this /// \c Decl represents a declaration for a body of code. @@ -996,24 +1006,24 @@ public: /// template parameter pack. bool isTemplateParameterPack() const; - /// \brief Whether this declaration is a parameter pack. + /// Whether this declaration is a parameter pack. bool isParameterPack() const; - /// \brief returns true if this declaration is a template + /// returns true if this declaration is a template bool isTemplateDecl() const; - /// \brief Whether this declaration is a function or function template. + /// Whether this declaration is a function or function template. bool isFunctionOrFunctionTemplate() const { return (DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction) || DeclKind == FunctionTemplate; } - /// \brief If this is a declaration that describes some template, this + /// If this is a declaration that describes some template, this /// method returns that template declaration. TemplateDecl *getDescribedTemplate() const; - /// \brief Returns the function itself, or the templated function if this is a + /// Returns the function itself, or the templated function if this is a /// function template. FunctionDecl *getAsFunction() LLVM_READONLY; @@ -1021,7 +1031,7 @@ public: return const_cast<Decl *>(this)->getAsFunction(); } - /// \brief Changes the namespace of this declaration to reflect that it's + /// Changes the namespace of this declaration to reflect that it's /// a function-local extern declaration. /// /// These declarations appear in the lexical context of the extern @@ -1042,14 +1052,14 @@ public: IdentifierNamespace |= IDNS_Ordinary; } - /// \brief Determine whether this is a block-scope declaration with linkage. + /// Determine whether this is a block-scope declaration with linkage. /// This will either be a local variable declaration declared 'extern', or a /// local function declaration. bool isLocalExternDecl() { return IdentifierNamespace & IDNS_LocalExtern; } - /// \brief Changes the namespace of this declaration to reflect that it's + /// Changes the namespace of this declaration to reflect that it's /// the object of a friend declaration. /// /// These declarations appear in the lexical context of the friending @@ -1091,7 +1101,7 @@ public: FOK_Undeclared ///< A friend of a previously-undeclared entity. }; - /// \brief Determines whether this declaration is the object of a + /// Determines whether this declaration is the object of a /// friend declaration and, if so, what kind. /// /// There is currently no direct way to find the associated FriendDecl. @@ -1131,7 +1141,7 @@ public: void dump(raw_ostream &Out, bool Deserialize = false) const; - /// \brief Looks through the Decl's underlying type to extract a FunctionType + /// Looks through the Decl's underlying type to extract a FunctionType /// when possible. Will return null if the type underlying the Decl does not /// have a FunctionType. const FunctionType *getFunctionType(bool BlocksToo = true) const; @@ -1145,7 +1155,7 @@ protected: ASTMutationListener *getASTMutationListener() const; }; -/// \brief Determine whether two declarations declare the same entity. +/// Determine whether two declarations declare the same entity. inline bool declaresSameEntity(const Decl *D1, const Decl *D2) { if (!D1 || !D2) return false; @@ -1172,7 +1182,7 @@ public: void print(raw_ostream &OS) const override; }; -/// \brief The results of name lookup within a DeclContext. This is either a +/// The results of name lookup within a DeclContext. This is either a /// single result (with no stable storage) or a collection of results (with /// stable storage provided by the lookup table). class DeclContextLookupResult { @@ -1253,36 +1263,36 @@ class DeclContext { /// DeclKind - This indicates which class this is. unsigned DeclKind : 8; - /// \brief Whether this declaration context also has some external + /// Whether this declaration context also has some external /// storage that contains additional declarations that are lexically /// part of this context. mutable bool ExternalLexicalStorage : 1; - /// \brief Whether this declaration context also has some external + /// Whether this declaration context also has some external /// storage that contains additional declarations that are visible /// in this context. mutable bool ExternalVisibleStorage : 1; - /// \brief Whether this declaration context has had external visible + /// Whether this declaration context has had external visible /// storage added since the last lookup. In this case, \c LookupPtr's /// invariant may not hold and needs to be fixed before we perform /// another lookup. mutable bool NeedToReconcileExternalVisibleStorage : 1; - /// \brief If \c true, this context may have local lexical declarations + /// If \c true, this context may have local lexical declarations /// that are missing from the lookup table. mutable bool HasLazyLocalLexicalLookups : 1; - /// \brief If \c true, the external source may have lexical declarations + /// If \c true, the external source may have lexical declarations /// that are missing from the lookup table. mutable bool HasLazyExternalLexicalLookups : 1; - /// \brief If \c true, lookups should only return identifier from + /// If \c true, lookups should only return identifier from /// DeclContext scope (for example TranslationUnit). Used in /// LookupQualifiedName() mutable bool UseQualifiedLookup : 1; - /// \brief Pointer to the data structure used to lookup declarations + /// Pointer to the data structure used to lookup declarations /// within this context (or a DependentStoredDeclsMap if this is a /// dependent context). We maintain the invariant that, if the map /// contains an entry for a DeclarationName (and we haven't lazily @@ -1305,7 +1315,7 @@ protected: /// another pointer. mutable Decl *LastDecl = nullptr; - /// \brief Build up a chain of declarations. + /// Build up a chain of declarations. /// /// \returns the first/last pair of declarations. static std::pair<Decl *, Decl *> @@ -1388,7 +1398,7 @@ public: } } - /// \brief Test whether the context supports looking up names. + /// Test whether the context supports looking up names. bool isLookupContext() const { return !isFunctionOrMethod() && DeclKind != Decl::LinkageSpec && DeclKind != Decl::Export; @@ -1414,7 +1424,7 @@ public: bool isInlineNamespace() const; - /// \brief Determines whether this context is dependent on a + /// Determines whether this context is dependent on a /// template parameter. bool isDependentContext() const; @@ -1435,28 +1445,28 @@ public: /// C++0x scoped enums), and C++ linkage specifications. bool isTransparentContext() const; - /// \brief Determines whether this context or some of its ancestors is a + /// Determines whether this context or some of its ancestors is a /// linkage specification context that specifies C linkage. bool isExternCContext() const; - /// \brief Retrieve the nearest enclosing C linkage specification context. + /// Retrieve the nearest enclosing C linkage specification context. const LinkageSpecDecl *getExternCContext() const; - /// \brief Determines whether this context or some of its ancestors is a + /// Determines whether this context or some of its ancestors is a /// linkage specification context that specifies C++ linkage. bool isExternCXXContext() const; - /// \brief Determine whether this declaration context is equivalent + /// Determine whether this declaration context is equivalent /// to the declaration context DC. bool Equals(const DeclContext *DC) const { return DC && this->getPrimaryContext() == DC->getPrimaryContext(); } - /// \brief Determine whether this declaration context encloses the + /// Determine whether this declaration context encloses the /// declaration context DC. bool Encloses(const DeclContext *DC) const; - /// \brief Find the nearest non-closure ancestor of this context, + /// Find the nearest non-closure ancestor of this context, /// i.e. the innermost semantic parent of this context which is not /// a closure. A context may be its own non-closure ancestor. Decl *getNonClosureAncestor(); @@ -1483,19 +1493,19 @@ public: return const_cast<DeclContext *>(this)->getRedeclContext(); } - /// \brief Retrieve the nearest enclosing namespace context. + /// Retrieve the nearest enclosing namespace context. DeclContext *getEnclosingNamespaceContext(); const DeclContext *getEnclosingNamespaceContext() const { return const_cast<DeclContext *>(this)->getEnclosingNamespaceContext(); } - /// \brief Retrieve the outermost lexically enclosing record context. + /// Retrieve the outermost lexically enclosing record context. RecordDecl *getOuterLexicalRecordContext(); const RecordDecl *getOuterLexicalRecordContext() const { return const_cast<DeclContext *>(this)->getOuterLexicalRecordContext(); } - /// \brief Test if this context is part of the enclosing namespace set of + /// Test if this context is part of the enclosing namespace set of /// the context NS, as defined in C++0x [namespace.def]p9. If either context /// isn't a namespace, this is equivalent to Equals(). /// @@ -1503,7 +1513,7 @@ public: /// inline, its enclosing namespace, recursively. bool InEnclosingNamespaceSetOf(const DeclContext *NS) const; - /// \brief Collects all of the declaration contexts that are semantically + /// Collects all of the declaration contexts that are semantically /// connected to this declaration context. /// /// For declaration contexts that have multiple semantically connected but @@ -1659,7 +1669,7 @@ public: } }; - /// \brief Iterates over a filtered subrange of declarations stored + /// Iterates over a filtered subrange of declarations stored /// in a DeclContext. /// /// This iterator visits only those declarations that are of type @@ -1735,7 +1745,7 @@ public: } }; - /// @brief Add the declaration D into this context. + /// Add the declaration D into this context. /// /// This routine should be invoked when the declaration D has first /// been declared, to place D into the context where it was @@ -1749,7 +1759,7 @@ public: /// semantic context via makeDeclVisibleInContext. void addDecl(Decl *D); - /// @brief Add the declaration D into this context, but suppress + /// Add the declaration D into this context, but suppress /// searches for external declarations with the same name. /// /// Although analogous in function to addDecl, this removes an @@ -1759,7 +1769,7 @@ public: /// See the ASTImporter for use cases. void addDeclInternal(Decl *D); - /// @brief Add the declaration D to this context without modifying + /// Add the declaration D to this context without modifying /// any lookup tables. /// /// This is useful for some operations in dependent contexts where @@ -1767,12 +1777,16 @@ public: /// only happens with friends. void addHiddenDecl(Decl *D); - /// @brief Removes a declaration from this context. + /// Removes a declaration from this context. void removeDecl(Decl *D); - - /// @brief Checks whether a declaration is in this context. + + /// Checks whether a declaration is in this context. bool containsDecl(Decl *D) const; + /// Checks whether a declaration is in this context. + /// This also loads the Decls from the external source before the check. + bool containsDeclAndLoad(Decl *D) const; + using lookup_result = DeclContextLookupResult; using lookup_iterator = lookup_result::iterator; @@ -1783,12 +1797,12 @@ public: /// routine will not look into parent contexts. lookup_result lookup(DeclarationName Name) const; - /// \brief Find the declarations with the given name that are visible + /// Find the declarations with the given name that are visible /// within this context; don't attempt to retrieve anything from an /// external source. lookup_result noload_lookup(DeclarationName Name); - /// \brief A simplistic name lookup mechanism that performs name lookup + /// A simplistic name lookup mechanism that performs name lookup /// into this declaration context without consulting the external source. /// /// This function should almost never be used, because it subverts the @@ -1800,7 +1814,7 @@ public: void localUncachedLookup(DeclarationName Name, SmallVectorImpl<NamedDecl *> &Results); - /// @brief Makes a declaration visible within this context. + /// Makes a declaration visible within this context. /// /// This routine makes the declaration D visible to name lookup /// within this context and, if this is a transparent context, @@ -1823,13 +1837,15 @@ public: using lookups_range = llvm::iterator_range<all_lookups_iterator>; lookups_range lookups() const; - lookups_range noload_lookups() const; + // Like lookups(), but avoids loading external declarations. + // If PreserveInternalState, avoids building lookup data structures too. + lookups_range noload_lookups(bool PreserveInternalState) const; - /// \brief Iterators over all possible lookups within this context. + /// Iterators over all possible lookups within this context. all_lookups_iterator lookups_begin() const; all_lookups_iterator lookups_end() const; - /// \brief Iterators over all possible lookups within this context that are + /// Iterators over all possible lookups within this context that are /// currently loaded; don't attempt to retrieve anything from an external /// source. all_lookups_iterator noload_lookups_begin() const; @@ -1861,7 +1877,7 @@ public: // Low-level accessors - /// \brief Mark that there are external lexical declarations that we need + /// Mark that there are external lexical declarations that we need /// to include in our lookup table (and that are not available as external /// visible lookups). These extra lookup results will be found by walking /// the lexical declarations of this context. This should be used only if @@ -1873,28 +1889,28 @@ public: HasLazyExternalLexicalLookups = true; } - /// \brief Retrieve the internal representation of the lookup structure. + /// Retrieve the internal representation of the lookup structure. /// This may omit some names if we are lazily building the structure. StoredDeclsMap *getLookupPtr() const { return LookupPtr; } - /// \brief Ensure the lookup structure is fully-built and return it. + /// Ensure the lookup structure is fully-built and return it. StoredDeclsMap *buildLookup(); - /// \brief Whether this DeclContext has external storage containing + /// Whether this DeclContext has external storage containing /// additional declarations that are lexically in this context. bool hasExternalLexicalStorage() const { return ExternalLexicalStorage; } - /// \brief State whether this DeclContext has external storage for + /// State whether this DeclContext has external storage for /// declarations lexically in this context. void setHasExternalLexicalStorage(bool ES = true) { ExternalLexicalStorage = ES; } - /// \brief Whether this DeclContext has external storage containing + /// Whether this DeclContext has external storage containing /// additional declarations that are visible in this context. bool hasExternalVisibleStorage() const { return ExternalVisibleStorage; } - /// \brief State whether this DeclContext has external storage for + /// State whether this DeclContext has external storage for /// declarations visible in this context. void setHasExternalVisibleStorage(bool ES = true) { ExternalVisibleStorage = ES; @@ -1902,7 +1918,7 @@ public: NeedToReconcileExternalVisibleStorage = true; } - /// \brief Determine whether the given declaration is stored in the list of + /// Determine whether the given declaration is stored in the list of /// declarations lexically within this context. bool isDeclInLexicalTraversal(const Decl *D) const { return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl || @@ -1933,7 +1949,7 @@ private: void reconcileExternalVisibleStorage() const; bool LoadLexicalDeclsFromExternalStorage() const; - /// @brief Makes a declaration visible within this context, but + /// Makes a declaration visible within this context, but /// suppresses searches for external declarations with the same /// name. /// @@ -1943,6 +1959,7 @@ private: StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const; + void loadLazyLocalLexicalLookups(); void buildLookupImpl(DeclContext *DCtx, bool Internal); void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Rediscoverable); |