15 #ifndef LLVM_CLANG_SEMA_LOOKUP_H
16 #define LLVM_CLANG_SEMA_LOOKUP_H
21 #include "llvm/ADT/Optional.h"
136 NamingClass(nullptr),
139 LookupKind(LookupKind),
141 Redecl(Redecl !=
Sema::NotForRedeclaration),
143 Diagnose(Redecl ==
Sema::NotForRedeclaration),
158 NamingClass(nullptr),
160 NameInfo(Name, NameLoc),
161 LookupKind(LookupKind),
163 Redecl(Redecl !=
Sema::NotForRedeclaration),
165 Diagnose(Redecl ==
Sema::NotForRedeclaration),
178 NamingClass(nullptr),
179 SemaPtr(Other.SemaPtr),
180 NameInfo(Other.NameInfo),
181 LookupKind(Other.LookupKind),
183 Redecl(Other.Redecl),
184 HideTags(Other.HideTags),
186 AllowHidden(Other.AllowHidden),
196 : ResultKind(std::move(Other.ResultKind)),
197 Ambiguity(std::move(Other.Ambiguity)), Decls(std::move(Other.Decls)),
198 Paths(std::move(Other.Paths)),
199 NamingClass(std::move(Other.NamingClass)),
200 BaseObjectType(std::move(Other.BaseObjectType)),
201 SemaPtr(std::move(Other.SemaPtr)), NameInfo(std::move(Other.NameInfo)),
202 NameContextRange(std::move(Other.NameContextRange)),
203 LookupKind(std::move(Other.LookupKind)), IDNS(std::move(Other.IDNS)),
204 Redecl(std::move(Other.Redecl)), HideTags(std::move(Other.HideTags)),
205 Diagnose(std::move(Other.Diagnose)),
206 AllowHidden(std::move(Other.AllowHidden)),
207 Shadowed(std::move(Other.Shadowed)) {
208 Other.Paths =
nullptr;
209 Other.Diagnose =
false;
212 ResultKind = std::move(Other.ResultKind);
213 Ambiguity = std::move(Other.Ambiguity);
214 Decls = std::move(Other.Decls);
215 Paths = std::move(Other.Paths);
216 NamingClass = std::move(Other.NamingClass);
217 BaseObjectType = std::move(Other.BaseObjectType);
218 SemaPtr = std::move(Other.SemaPtr);
219 NameInfo = std::move(Other.NameInfo);
220 NameContextRange = std::move(Other.NameContextRange);
221 LookupKind = std::move(Other.LookupKind);
222 IDNS = std::move(Other.IDNS);
223 Redecl = std::move(Other.Redecl);
224 HideTags = std::move(Other.HideTags);
225 Diagnose = std::move(Other.Diagnose);
226 AllowHidden = std::move(Other.AllowHidden);
227 Shadowed = std::move(Other.Shadowed);
228 Other.Paths =
nullptr;
229 Other.Diagnose =
false;
234 if (Diagnose) diagnose();
235 if (Paths) deletePaths(Paths);
245 this->NameInfo = NameInfo;
277 return AllowHidden ||
342 return isVisibleSlow(SemaRef, D);
354 return getAcceptableDeclSlow(D);
370 return NamingClass !=
nullptr;
395 NamingClass = Record;
402 return BaseObjectType;
471 bool WasAmbiguous =
false;
483 assert(WasAmbiguous);
484 Ambiguity = SavedAK.getValue();
492 template <
class DeclClass>
505 &&
"getFoundDecl called on non-unique result");
506 return (*
begin())->getUnderlyingDecl();
511 assert(!Decls.
empty() &&
"cannot get representative of empty set");
543 if (Paths) deletePaths(Paths);
545 NamingClass =
nullptr;
564 void print(raw_ostream &);
579 NameContextRange = SR;
586 return NameContextRange;
615 : Results(F.Results),
I(F.
I), Changed(F.Changed),
616 CalledDone(F.CalledDone) {
621 "LookupResult::Filter destroyed without done() call");
625 return I != Results.
end();
629 assert(
I != Results.
end() &&
"next() called on empty filter");
658 assert(!CalledDone &&
"done() called twice");
675 IDNS &= ~
Decl::IDNS_LocalExtern;
691 void addDeclsFromBasePaths(
const CXXBasePaths &
P);
697 bool sanityCheckUnresolved()
const {
699 if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
704 static void deletePaths(CXXBasePaths *);
709 UnresolvedSet<8> Decls;
711 CXXRecordDecl *NamingClass;
712 QualType BaseObjectType;
716 DeclarationNameInfo NameInfo;
717 SourceRange NameContextRange;
767 bool InBaseClass) = 0;
774 llvm::MapVector<NamedDecl*, NamedDecl*> Decls;
776 struct select_second {
777 NamedDecl *operator()(std::pair<NamedDecl*, NamedDecl*>
P)
const {
791 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.
Decl - This represents one declaration (or definition), e.g.
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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].
AccessSpecifier getAccess() const
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.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
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.
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.
bool isInIdentifierNamespace(unsigned NS) const
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
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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.
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.
This declaration is a function-local extern declaration of a variable or function.
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.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.