14 #ifndef LLVM_CLANG_SEMA_LOOKUP_H 15 #define LLVM_CLANG_SEMA_LOOKUP_H 28 #include "llvm/ADT/MapVector.h" 29 #include "llvm/ADT/Optional.h" 30 #include "llvm/ADT/STLExtras.h" 31 #include "llvm/Support/Casting.h" 148 : SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
149 Redecl(Redecl !=
Sema::NotForRedeclaration),
150 ExternalRedecl(Redecl ==
Sema::ForExternalRedeclaration),
151 Diagnose(Redecl ==
Sema::NotForRedeclaration) {
161 : SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
162 Redecl(Redecl !=
Sema::NotForRedeclaration),
163 ExternalRedecl(Redecl ==
Sema::ForExternalRedeclaration),
164 Diagnose(Redecl ==
Sema::NotForRedeclaration) {
172 : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
173 LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
174 ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
175 AllowHidden(Other.AllowHidden),
176 TemplateNameLookup(Other.TemplateNameLookup) {}
184 : ResultKind(
std::move(Other.ResultKind)),
185 Ambiguity(
std::move(Other.Ambiguity)), Decls(
std::move(Other.Decls)),
186 Paths(
std::move(Other.Paths)),
187 NamingClass(
std::move(Other.NamingClass)),
188 BaseObjectType(
std::move(Other.BaseObjectType)),
189 SemaPtr(
std::move(Other.SemaPtr)), NameInfo(
std::move(Other.NameInfo)),
190 NameContextRange(
std::move(Other.NameContextRange)),
191 LookupKind(
std::move(Other.LookupKind)), IDNS(
std::move(Other.IDNS)),
192 Redecl(
std::move(Other.Redecl)),
193 ExternalRedecl(
std::move(Other.ExternalRedecl)),
194 HideTags(
std::move(Other.HideTags)),
195 Diagnose(
std::move(Other.Diagnose)),
196 AllowHidden(
std::move(Other.AllowHidden)),
197 Shadowed(
std::move(Other.Shadowed)),
198 TemplateNameLookup(
std::move(Other.TemplateNameLookup)) {
199 Other.Paths =
nullptr;
200 Other.Diagnose =
false;
204 ResultKind = std::move(Other.ResultKind);
205 Ambiguity = std::move(Other.Ambiguity);
206 Decls = std::move(Other.Decls);
207 Paths = std::move(Other.Paths);
208 NamingClass = std::move(Other.NamingClass);
209 BaseObjectType = std::move(Other.BaseObjectType);
210 SemaPtr = std::move(Other.SemaPtr);
211 NameInfo = std::move(Other.NameInfo);
212 NameContextRange = std::move(Other.NameContextRange);
213 LookupKind = std::move(Other.LookupKind);
214 IDNS = std::move(Other.IDNS);
215 Redecl = std::move(Other.Redecl);
216 ExternalRedecl = std::move(Other.ExternalRedecl);
217 HideTags = std::move(Other.HideTags);
218 Diagnose = std::move(Other.Diagnose);
219 AllowHidden = std::move(Other.AllowHidden);
220 Shadowed = std::move(Other.Shadowed);
221 TemplateNameLookup = std::move(Other.TemplateNameLookup);
222 Other.Paths =
nullptr;
223 Other.Diagnose =
false;
228 if (Diagnose) diagnose();
229 if (Paths) deletePaths(Paths);
239 this->NameInfo = NameInfo;
265 return ExternalRedecl;
282 return AllowHidden ||
296 TemplateNameLookup = TemplateName;
356 return isVisibleSlow(SemaRef, D);
368 return getAcceptableDeclSlow(D);
384 return NamingClass !=
nullptr;
409 NamingClass = Record;
416 return BaseObjectType;
485 bool WasAmbiguous =
false;
497 assert(WasAmbiguous);
498 Ambiguity = SavedAK.getValue();
506 template <
class DeclClass>
519 &&
"getFoundDecl called on non-unique result");
520 return (*
begin())->getUnderlyingDecl();
525 assert(!Decls.
empty() &&
"cannot get representative of empty set");
554 LLVM_ATTRIBUTE_REINITIALIZES
void clear() {
557 if (Paths) deletePaths(Paths);
559 NamingClass =
nullptr;
579 void print(raw_ostream &);
594 NameContextRange = SR;
601 return NameContextRange;
622 bool Changed =
false;
623 bool CalledDone =
false;
629 : Results(F.Results), I(F.I), Changed(F.Changed),
630 CalledDone(F.CalledDone) {
636 "LookupResult::Filter destroyed without done() call");
640 return I != Results.
end();
644 assert(I != Results.
end() &&
"next() called on empty filter");
655 Results.Decls.
erase(--I);
668 Results.Decls.
replace(I-1, D, AS);
673 assert(!CalledDone &&
"done() called twice");
690 IDNS &= ~
Decl::IDNS_LocalExtern;
712 bool sanityCheckUnresolved()
const {
714 if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
743 bool HideTags =
true;
745 bool Diagnose =
false;
748 bool AllowHidden =
false;
753 bool Shadowed =
false;
756 bool TemplateNameLookup =
false;
773 virtual bool includeHiddenDecls()
const;
788 bool InBaseClass) = 0;
801 llvm::MapVector<NamedDecl*, NamedDecl*> Decls;
803 struct select_second {
804 NamedDecl *operator()(std::pair<NamedDecl*, NamedDecl*>
P)
const {
819 llvm::mapped_iterator<decltype(Decls)::iterator, select_second>;
827 #endif // LLVM_CLANG_SEMA_LOOKUP_H 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.
void setLookupName(DeclarationName Name)
Sets the name to look up.
AmbiguityKind getAmbiguityKind() const
Filter makeFilter()
Create a filter for this result set.
C Language Family Type Representation.
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.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
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
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...
bool isTemplateNameLookup() const
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...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
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.
virtual void EnteredContext(DeclContext *Ctx)
Callback to inform the client that Sema entered into a new context to find a visible declaration...
Defines the clang::LangOptions interface.
LookupNameKind
Describes the kind of name lookup to perform.
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 ...
Represents a C++ template name within the type system.
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.
UnresolvedSetIterator iterator
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.
void setTemplateNameLookup(bool TemplateName)
Sets whether this is a template-name lookup.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
UnresolvedSetImpl::iterator iterator
Defines various enumerations that describe declaration and type specifiers.
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.
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).
Defines the clang::SourceLocation class and associated facilities.
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.
This represents a decl that may have 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 setFindLocalExtern(bool FindLocalExtern)
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.