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),
142 ExternalRedecl(Redecl ==
Sema::ForExternalRedeclaration),
144 Diagnose(Redecl ==
Sema::NotForRedeclaration),
159 NamingClass(nullptr),
161 NameInfo(Name, NameLoc),
162 LookupKind(LookupKind),
164 Redecl(Redecl !=
Sema::NotForRedeclaration),
165 ExternalRedecl(Redecl ==
Sema::ForExternalRedeclaration),
167 Diagnose(Redecl ==
Sema::NotForRedeclaration),
180 NamingClass(nullptr),
181 SemaPtr(Other.SemaPtr),
182 NameInfo(Other.NameInfo),
183 LookupKind(Other.LookupKind),
185 Redecl(Other.Redecl),
186 ExternalRedecl(Other.ExternalRedecl),
187 HideTags(Other.HideTags),
189 AllowHidden(Other.AllowHidden),
199 : ResultKind(
std::move(Other.ResultKind)),
200 Ambiguity(
std::move(Other.Ambiguity)), Decls(
std::move(Other.Decls)),
201 Paths(
std::move(Other.Paths)),
202 NamingClass(
std::move(Other.NamingClass)),
203 BaseObjectType(
std::move(Other.BaseObjectType)),
204 SemaPtr(
std::move(Other.SemaPtr)), NameInfo(
std::move(Other.NameInfo)),
205 NameContextRange(
std::move(Other.NameContextRange)),
206 LookupKind(
std::move(Other.LookupKind)), IDNS(
std::move(Other.IDNS)),
207 Redecl(
std::move(Other.Redecl)),
208 ExternalRedecl(
std::move(Other.ExternalRedecl)),
209 HideTags(
std::move(Other.HideTags)),
210 Diagnose(
std::move(Other.Diagnose)),
211 AllowHidden(
std::move(Other.AllowHidden)),
212 Shadowed(
std::move(Other.Shadowed)) {
213 Other.Paths =
nullptr;
214 Other.Diagnose =
false;
217 ResultKind = std::move(Other.ResultKind);
218 Ambiguity = std::move(Other.Ambiguity);
219 Decls = std::move(Other.Decls);
220 Paths = std::move(Other.Paths);
221 NamingClass = std::move(Other.NamingClass);
222 BaseObjectType = std::move(Other.BaseObjectType);
223 SemaPtr = std::move(Other.SemaPtr);
224 NameInfo = std::move(Other.NameInfo);
225 NameContextRange = std::move(Other.NameContextRange);
226 LookupKind = std::move(Other.LookupKind);
227 IDNS = std::move(Other.IDNS);
228 Redecl = std::move(Other.Redecl);
229 ExternalRedecl = std::move(Other.ExternalRedecl);
230 HideTags = std::move(Other.HideTags);
231 Diagnose = std::move(Other.Diagnose);
232 AllowHidden = std::move(Other.AllowHidden);
233 Shadowed = std::move(Other.Shadowed);
234 Other.Paths =
nullptr;
235 Other.Diagnose =
false;
240 if (Diagnose) diagnose();
241 if (Paths) deletePaths(Paths);
251 this->NameInfo = NameInfo;
277 return ExternalRedecl;
294 return AllowHidden ||
359 return isVisibleSlow(SemaRef, D);
371 return getAcceptableDeclSlow(D);
387 return NamingClass !=
nullptr;
412 NamingClass = Record;
419 return BaseObjectType;
488 bool WasAmbiguous =
false;
500 assert(WasAmbiguous);
501 Ambiguity = SavedAK.getValue();
509 template <
class DeclClass>
522 &&
"getFoundDecl called on non-unique result");
523 return (*
begin())->getUnderlyingDecl();
528 assert(!Decls.
empty() &&
"cannot get representative of empty set");
560 if (Paths) deletePaths(Paths);
562 NamingClass =
nullptr;
582 void print(raw_ostream &);
597 NameContextRange = SR;
604 return NameContextRange;
628 : Results(Results), I(Results.
begin()), Changed(
false), CalledDone(
false)
633 : Results(F.Results), I(F.I), Changed(F.Changed),
634 CalledDone(F.CalledDone) {
639 "LookupResult::Filter destroyed without done() call");
643 return I != Results.
end();
647 assert(I != Results.
end() &&
"next() called on empty filter");
658 Results.Decls.
erase(--I);
671 Results.Decls.
replace(I-1, D, AS);
676 assert(!CalledDone &&
"done() called twice");
693 IDNS &= ~
Decl::IDNS_LocalExtern;
715 bool sanityCheckUnresolved()
const {
716 for (iterator I =
begin(), E =
end(); I != E; ++I)
717 if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
771 virtual bool includeHiddenDecls()
const;
786 bool InBaseClass) = 0;
793 llvm::MapVector<NamedDecl*, NamedDecl*> Decls;
795 struct select_second {
796 NamedDecl *operator()(std::pair<NamedDecl*, NamedDecl*>
P)
const {
810 typedef llvm::mapped_iterator<decltype(Decls)::iterator, select_second>
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
Name lookup found a set of overloaded functions that met the criteria.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
void restart()
Restart the iteration.
A (possibly-)qualified type.
UnresolvedSetImpl::iterator iterator
void setLookupName(DeclarationName Name)
Sets the name to look up.
AmbiguityKind getAmbiguityKind() const
Filter makeFilter()
Create a filter for this result set.
bool isForExternalRedeclaration() const
True if this lookup is just looking for an existing declaration to link against a declaration with ex...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
void erase()
Erase the last element returned from this iterator.
QualType getBaseObjectType() const
Returns the base object type associated with this lookup; important for [class.protected].
Decl - This represents one declaration (or definition), e.g.
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...
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
void resolveKindAfterFilter()
Re-resolves the result kind of the lookup after a set of removals has been performed.
bool isClassLookup() const
Returns whether these results arose from performing a lookup into a class.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
DeclarationName getLookupName() const
Gets the name to look up.
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...
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.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
The iterator over UnresolvedSets.
bool isInIdentifierNamespace(unsigned NS) const
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
LookupResultKind getResultKind() const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
DeclClass * getAsSingle() const
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
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...
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
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)
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.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Sema::RedeclarationKind redeclarationKind() const
Sema - This implements semantic analysis and AST building for C.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
LookupNameKind
Describes the kind of name lookup to perform.
const FunctionProtoType * T
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl=Sema::NotForRedeclaration)
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...
bool isUnresolvableResult() const
TemporaryToken
A little identifier for flagging temporary lookup results.
Encodes a location in the source.
bool isHiddenDeclarationVisible(NamedDecl *ND) const
Determine whether this lookup is permitted to see hidden declarations, such as those in modules that ...
DeclarationName getName() const
getName - Returns the embedded declaration name.
bool isOverloadedResult() const
Determines if the results are overloaded.
Name lookup found an unresolvable value declaration and cannot yet complete.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
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.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
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)
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
void setContextRange(SourceRange SR)
Sets a 'context' source range.
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...
AccessSpecifier getAccess() const
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
DeclarationName - The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Name lookup found a single declaration that met the criteria.
const UnresolvedSetImpl & asUnresolvedSet() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
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 &)
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
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.
bool empty() const
Return true if no decls were found.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
SourceLocation getNameLoc() const
Gets the location of the identifier.
void clear(Sema::LookupNameKind Kind)
Clears out any current state and re-initializes for a different kind of lookup.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void setLookupNameInfo(const DeclarationNameInfo &NameInfo)
Sets the name info to look up.
void clear()
Clears out any current state.
void setFindLocalExtern(bool FindLocalExtern)
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.