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),
142 AllowHidden(Redecl ==
Sema::ForRedeclaration),
156 NamingClass(nullptr),
158 NameInfo(Name, NameLoc),
159 LookupKind(LookupKind),
161 Redecl(Redecl !=
Sema::NotForRedeclaration),
163 Diagnose(Redecl ==
Sema::NotForRedeclaration),
164 AllowHidden(Redecl ==
Sema::ForRedeclaration),
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),
189 if (Diagnose) diagnose();
190 if (Paths) deletePaths(Paths);
200 this->NameInfo = NameInfo;
296 return isVisibleSlow(SemaRef, D);
308 return getAcceptableDeclSlow(D);
324 return NamingClass !=
nullptr;
349 NamingClass = Record;
356 return BaseObjectType;
425 bool WasAmbiguous =
false;
437 assert(WasAmbiguous);
446 template <
class DeclClass>
459 &&
"getFoundDecl called on non-unique result");
460 return (*
begin())->getUnderlyingDecl();
465 assert(!Decls.
empty() &&
"cannot get representative of empty set");
497 if (Paths) deletePaths(Paths);
499 NamingClass =
nullptr;
518 void print(raw_ostream &);
533 NameContextRange = SR;
540 return NameContextRange;
564 : Results(Results), I(Results.
begin()), Changed(
false), CalledDone(
false)
570 "LookupResult::Filter destroyed without done() call");
574 return I != Results.
end();
578 assert(I != Results.
end() &&
"next() called on empty filter");
589 Results.Decls.
erase(--I);
602 Results.Decls.
replace(I-1, D, AS);
607 assert(!CalledDone &&
"done() called twice");
624 IDNS &= ~
Decl::IDNS_LocalExtern;
640 void addDeclsFromBasePaths(
const CXXBasePaths &
P);
646 bool sanityCheckUnresolved()
const {
648 if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
653 static void deletePaths(CXXBasePaths *);
658 UnresolvedSet<8> Decls;
660 CXXRecordDecl *NamingClass;
661 QualType BaseObjectType;
665 DeclarationNameInfo NameInfo;
666 SourceRange NameContextRange;
716 bool InBaseClass) = 0;
723 llvm::DenseMap<NamedDecl*, NamedDecl*> Decls;
735 :
public llvm::iterator_adaptor_base<
736 iterator, llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator,
737 std::forward_iterator_tag, NamedDecl *> {
740 iterator(llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator Iter)
741 : iterator_adaptor_base(std::move(Iter)) {}
Name lookup found a set of overloaded functions that met the criteria.
void restart()
Restart the iteration.
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.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs. a reference).
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isHiddenDeclarationVisible() const
Determine whether this lookup is permitted to see hidden declarations, such as those in modules that ...
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]. Most lookups do not have an associated base object.
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.
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)
LookupResult(TemporaryToken _, const LookupResult &Other)
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
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
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. Does not test the acceptance criteria...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
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.
value_type operator*() const
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. the class which was looked into to find these result...
void setHideTags(bool Hide)
SourceLocation getNameLoc() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
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)
TemporaryToken
A little identifier for flagging temporary lookup results.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
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. This only happens in C++...
void addDecl(NamedDecl *D)
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. Does not test the acceptance criteria...
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)
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.
bool isClassLookup() const
Returns whether these results arose from performing a lookup into a class.
bool isSingleResult() const
bool empty() const
Return true if no decls were found.
Name lookup found a single declaration that met the criteria. getFoundDecl() will return this declara...
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.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
void suppressDiagnostics()
A trivial tuple used to represent a source range.
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.