diff options
Diffstat (limited to 'include/clang/Sema/Lookup.h')
-rw-r--r-- | include/clang/Sema/Lookup.h | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index 6630bb2..fe5d262 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -214,6 +214,12 @@ public: return Redecl; } + /// \brief Determine whether this lookup is permitted to see hidden + /// declarations, such as those in modules that have not yet been imported. + bool isHiddenDeclarationVisible() const { + return Redecl || LookupKind == Sema::LookupTagName; + } + /// Sets whether tag declarations should be hidden by non-tag /// declarations during resolution. The default is true. void setHideTags(bool Hide) { @@ -266,23 +272,35 @@ public: return Paths; } - /// \brief Tests whether the given declaration is acceptable. - bool isAcceptableDecl(NamedDecl *D) const { - if (!D->isInIdentifierNamespace(IDNS)) - return false; - - // So long as this declaration is not module-private or was parsed as - // part of this translation unit (i.e., in the module), we're allowed to - // find it. - if (!D->isModulePrivate() || !D->isFromASTFile()) + /// \brief Determine whether the given declaration is visible to the + /// program. + static bool isVisible(NamedDecl *D) { + // If this declaration is not hidden, it's visible. + if (!D->isHidden()) return true; - + // FIXME: We should be allowed to refer to a module-private name from // within the same module, e.g., during template instantiation. // This requires us know which module a particular declaration came from. return false; } - + + /// \brief Retrieve the accepted (re)declaration of the given declaration, + /// if there is one. + NamedDecl *getAcceptableDecl(NamedDecl *D) const { + if (!D->isInIdentifierNamespace(IDNS)) + return 0; + + if (isHiddenDeclarationVisible() || isVisible(D)) + return D; + + return getAcceptableDeclSlow(D); + } + +private: + NamedDecl *getAcceptableDeclSlow(NamedDecl *D) const; +public: + /// \brief Returns the identifier namespace mask for this lookup. unsigned getIdentifierNamespace() const { return IDNS; @@ -532,6 +550,11 @@ public: return *I++; } + /// Restart the iteration. + void restart() { + I = Results.begin(); + } + /// Erase the last element returned from this iterator. void erase() { Results.Decls.erase(--I); @@ -569,7 +592,7 @@ private: void diagnose() { if (isAmbiguous()) SemaRef.DiagnoseAmbiguousLookup(*this); - else if (isClassLookup() && SemaRef.getLangOptions().AccessControl) + else if (isClassLookup() && SemaRef.getLangOpts().AccessControl) SemaRef.CheckLookupAccess(*this); } @@ -582,7 +605,13 @@ private: void configure(); // Sanity checks. - void sanity() const; + void sanityImpl() const; + + void sanity() const { +#ifndef NDEBUG + sanityImpl(); +#endif + } bool sanityCheckUnresolved() const { for (iterator I = begin(), E = end(); I != E; ++I) |