15 #ifndef LLVM_CLANG_SEMA_LOOKUP_H
16 #define LLVM_CLANG_SEMA_LOOKUP_H
134 NamingClass(nullptr),
137 LookupKind(LookupKind),
139 Redecl(Redecl !=
Sema::NotForRedeclaration),
141 Diagnose(Redecl ==
Sema::NotForRedeclaration),
156 NamingClass(nullptr),
158 NameInfo(Name, NameLoc),
159 LookupKind(LookupKind),
161 Redecl(Redecl !=
Sema::NotForRedeclaration),
163 Diagnose(Redecl ==
Sema::NotForRedeclaration),
176 NamingClass(nullptr),
177 SemaPtr(Other.SemaPtr),
178 NameInfo(Other.NameInfo),
179 LookupKind(Other.LookupKind),
181 Redecl(Other.Redecl),
182 HideTags(Other.HideTags),
184 AllowHidden(Other.AllowHidden),
194 : ResultKind(std::move(Other.ResultKind)),
195 Ambiguity(std::move(Other.Ambiguity)), Decls(std::move(Other.Decls)),
196 Paths(std::move(Other.Paths)),
197 NamingClass(std::move(Other.NamingClass)),
198 BaseObjectType(std::move(Other.BaseObjectType)),
199 SemaPtr(std::move(Other.SemaPtr)), NameInfo(std::move(Other.NameInfo)),
200 NameContextRange(std::move(Other.NameContextRange)),
201 LookupKind(std::move(Other.LookupKind)), IDNS(std::move(Other.IDNS)),
202 Redecl(std::move(Other.Redecl)), HideTags(std::move(Other.HideTags)),
203 Diagnose(std::move(Other.Diagnose)),
204 AllowHidden(std::move(Other.AllowHidden)),
205 Shadowed(std::move(Other.Shadowed)) {
206 Other.Paths =
nullptr;
207 Other.Diagnose =
false;
210 ResultKind = std::move(Other.ResultKind);
211 Ambiguity = std::move(Other.Ambiguity);
212 Decls = std::move(Other.Decls);
213 Paths = std::move(Other.Paths);
214 NamingClass = std::move(Other.NamingClass);
215 BaseObjectType = std::move(Other.BaseObjectType);
216 SemaPtr = std::move(Other.SemaPtr);
217 NameInfo = std::move(Other.NameInfo);
218 NameContextRange = std::move(Other.NameContextRange);
219 LookupKind = std::move(Other.LookupKind);
220 IDNS = std::move(Other.IDNS);
221 Redecl = std::move(Other.Redecl);
222 HideTags = std::move(Other.HideTags);
223 Diagnose = std::move(Other.Diagnose);
224 AllowHidden = std::move(Other.AllowHidden);
225 Shadowed = std::move(Other.Shadowed);
226 Other.Paths =
nullptr;
227 Other.Diagnose =
false;
232 if (Diagnose) diagnose();
233 if (Paths) deletePaths(Paths);
243 this->NameInfo = NameInfo;
275 return AllowHidden ||
340 return isVisibleSlow(SemaRef, D);
346 if (!D->isInIdentifierNamespace(IDNS))
352 return getAcceptableDeclSlow(D);
368 return NamingClass !=
nullptr;
393 NamingClass = Record;
400 return BaseObjectType;
469 bool WasAmbiguous =
false;
481 assert(WasAmbiguous);
490 template <
class DeclClass>
503 &&
"getFoundDecl called on non-unique result");
504 return (*
begin())->getUnderlyingDecl();
509 assert(!Decls.
empty() &&
"cannot get representative of empty set");
541 if (Paths) deletePaths(Paths);
543 NamingClass =
nullptr;
562 void print(raw_ostream &);
577 NameContextRange = SR;
584 return NameContextRange;
613 : Results(F.Results),
I(F.
I), Changed(F.Changed),
614 CalledDone(F.CalledDone) {
619 "LookupResult::Filter destroyed without done() call");
623 return I != Results.
end();
627 assert(
I != Results.
end() &&
"next() called on empty filter");
656 assert(!CalledDone &&
"done() called twice");
671 IDNS |= Decl::IDNS_LocalExtern;
673 IDNS &= ~
Decl::IDNS_LocalExtern;
689 void addDeclsFromBasePaths(
const CXXBasePaths &
P);
695 bool sanityCheckUnresolved()
const {
697 if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
702 static void deletePaths(CXXBasePaths *);
707 UnresolvedSet<8> Decls;
709 CXXRecordDecl *NamingClass;
710 QualType BaseObjectType;
714 DeclarationNameInfo NameInfo;
715 SourceRange NameContextRange;
765 bool InBaseClass) = 0;
772 llvm::MapVector<NamedDecl*, NamedDecl*> Decls;
774 struct select_second {
775 NamedDecl *operator()(std::pair<NamedDecl*, NamedDecl*>
P)
const {
786 Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
789 typedef llvm::mapped_iterator<decltype(Decls)::iterator, select_second>
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
Name lookup found a set of overloaded functions that met the criteria.
void restart()
Restart the iteration.
A (possibly-)qualified type.
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
UnresolvedSetImpl::iterator iterator
void setLookupName(DeclarationName Name)
Sets the name to look up.
DeclClass * getAsSingle() const
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Filter makeFilter()
Create a filter for this result set.
void erase()
Erase the last element returned from this iterator.
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
void resolveKindAfterFilter()
Re-resolves the result kind of the lookup after a set of removals has been performed.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
QualType getBaseObjectType() const
Returns the base object type associated with this lookup; important for [class.protected].
bool isUnresolvableResult() const
void CheckLookupAccess(const LookupResult &R)
Checks access to all the declarations in the given result set.
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
void replace(NamedDecl *D)
Replaces the current entry with the given one, preserving the access bits.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
LookupResult & operator=(const LookupResult &)=delete
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
LookupResult(TemporaryToken _, const LookupResult &Other)
Creates a temporary lookup result, initializing its core data using the information from another resu...
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
The iterator over UnresolvedSets.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents the results of name lookup.
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type...
AmbiguityKind getAmbiguityKind() const
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
A set of unresolved declarations.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
void append(iterator I, iterator E)
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
detail::InMemoryDirectory::const_iterator I
const UnresolvedSetImpl & asUnresolvedSet() const
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Sema - This implements semantic analysis and AST building for C.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
SourceLocation getNameLoc() const
Gets the location of the identifier.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
bool isExternallyVisible() const
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl=Sema::NotForRedeclaration)
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
bool replace(const NamedDecl *Old, NamedDecl *New)
Replaces the given declaration with the new one, once.
LookupResult & operator=(LookupResult &&Other)
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
TemporaryToken
A little identifier for flagging temporary lookup results.
Encodes a location in the source.
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
Name lookup found an unresolvable value declaration and cannot yet complete.
void addDecl(NamedDecl *D)
A class for iterating through a result set and possibly filtering out results.
LookupResult(LookupResult &&Other)
No entity found met the criteria.
A class for storing results from argument-dependent lookup.
void addDecl(NamedDecl *D, AccessSpecifier AS)
Add a declaration to these results with the given access.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl=Sema::NotForRedeclaration)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void setContextRange(SourceRange SR)
Sets a 'context' source range.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
void replace(NamedDecl *D, AccessSpecifier AS)
Replaces the current entry with the given one.
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
DeclarationName - The name of a declaration.
detail::InMemoryDirectory::const_iterator E
bool isClassLookup() const
Returns whether these results arose from performing a lookup into a class.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isHiddenDeclarationVisible(NamedDecl *ND) const
Determine whether this lookup is permitted to see hidden declarations, such as those in modules that ...
bool empty() const
Return true if no decls were found.
Name lookup found a single declaration that met the criteria.
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
void print(raw_ostream &)
LookupResultKind getResultKind() const
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void clear(Sema::LookupNameKind Kind)
Clears out any current state and re-initializes for a different kind of lookup.
void setLookupNameInfo(const DeclarationNameInfo &NameInfo)
Sets the name info to look up.
void clear()
Clears out any current state.
void setFindLocalExtern(bool FindLocalExtern)
bool isOverloadedResult() const
Determines if the results are overloaded.
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.