class LookupResult

Declaration

class LookupResult { /* full declaration omitted */ };

Description

Represents the results of name lookup. An instance of the LookupResult class captures the results of a single name lookup, which can return no result (nothing found), a single declaration, a set of overloaded functions, or an ambiguity. Use the getKind() method to determine which of these results occurred for a given lookup.

Declared at: clang/include/clang/Sema/Lookup.h:46

Member Variables

private clang::LookupResult::LookupResultKind ResultKind = NotFound
private clang::LookupResult::AmbiguityKind Ambiguity = {}
private UnresolvedSet<8> Decls
private clang::CXXBasePaths* Paths = nullptr
private clang::CXXRecordDecl* NamingClass = nullptr
private clang::QualType BaseObjectType
private clang::Sema* SemaPtr
private clang::DeclarationNameInfo NameInfo
private clang::SourceRange NameContextRange
private Sema::LookupNameKind LookupKind
private unsigned int IDNS = 0
private bool Redecl
private bool ExternalRedecl
private bool HideTags = true
True if tag declarations should be hidden if non-tags are present
private bool Diagnose = false
private bool AllowHidden = false
True if we should allow hidden declarations to be 'visible'.
private bool Shadowed = false
True if the found declarations were shadowed by some other declaration that we skipped. This only happens when \c LookupKind is \c LookupRedeclarationWithLinkage.
private bool TemplateNameLookup = false
True if we're looking up a template-name.

Method Overview

Methods

LookupResult(clang::Sema& SemaRef,
             clang::DeclarationName Name,
             clang::SourceLocation NameLoc,
             Sema::LookupNameKind LookupKind,
             Sema::RedeclarationKind Redecl =
                 Sema::NotForRedeclaration)

Declared at: clang/include/clang/Sema/Lookup.h:158

Parameters

clang::Sema& SemaRef
clang::DeclarationName Name
clang::SourceLocation NameLoc
Sema::LookupNameKind LookupKind
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration

LookupResult(
    clang::LookupResult::TemporaryToken _,
    const clang::LookupResult& Other)

Description

Creates a temporary lookup result, initializing its core data using the information from another result. Diagnostics are always disabled.

Declared at: clang/include/clang/Sema/Lookup.h:171

Parameters

clang::LookupResult::TemporaryToken _
const clang::LookupResult& Other

LookupResult(const clang::LookupResult&)

Declared at: clang/include/clang/Sema/Lookup.h:180

Parameters

const clang::LookupResult&

LookupResult(clang::LookupResult&& Other)

Declared at: clang/include/clang/Sema/Lookup.h:183

Parameters

clang::LookupResult&& Other

LookupResult(
    clang::Sema& SemaRef,
    const clang::DeclarationNameInfo& NameInfo,
    Sema::LookupNameKind LookupKind,
    Sema::RedeclarationKind Redecl =
        Sema::NotForRedeclaration)

Declared at: clang/include/clang/Sema/Lookup.h:145

Parameters

clang::Sema& SemaRef
const clang::DeclarationNameInfo& NameInfo
Sema::LookupNameKind LookupKind
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration

void addAllDecls(const clang::LookupResult& Other)

Description

Add all the declarations from another set of lookup results.

Declared at: clang/include/clang/Sema/Lookup.h:465

Parameters

const clang::LookupResult& Other

void addDecl(clang::NamedDecl* D)

Description

Add a declaration to these results with its natural access. Does not test the acceptance criteria.

Declared at: clang/include/clang/Sema/Lookup.h:452

Parameters

clang::NamedDecl* D

void addDecl(clang::NamedDecl* D,
             clang::AccessSpecifier AS)

Description

Add a declaration to these results with the given access. Does not test the acceptance criteria.

Declared at: clang/include/clang/Sema/Lookup.h:458

Parameters

clang::NamedDecl* D
clang::AccessSpecifier AS

void addDeclsFromBasePaths(
    const clang::CXXBasePaths& P)

Declared at: clang/include/clang/Sema/Lookup.h:732

Parameters

const clang::CXXBasePaths& P

const clang::UnresolvedSetImpl& asUnresolvedSet()
    const

Declared at: clang/include/clang/Sema/Lookup.h:331

clang::LookupResult::iterator begin() const

Declared at: clang/include/clang/Sema/Lookup.h:335

bool checkDebugAssumptions() const

Declared at: clang/include/clang/Sema/Lookup.h:735

bool checkUnresolved() const

Declared at: clang/include/clang/Sema/Lookup.h:737

void clear(Sema::LookupNameKind Kind)

Description

Clears out any current state and re-initializes for a different kind of lookup.

Declared at: clang/include/clang/Sema/Lookup.h:591

Parameters

Sema::LookupNameKind Kind

void clear()

Description

Clears out any current state.

Declared at: clang/include/clang/Sema/Lookup.h:580

void configure()

Declared at: clang/include/clang/Sema/Lookup.h:733

static void deletePaths(clang::CXXBasePaths*)

Declared at: clang/include/clang/Sema/Lookup.h:744

Parameters

clang::CXXBasePaths*

void diagnose()

Declared at: clang/include/clang/Sema/Lookup.h:720

void dump()

Declared at: clang/include/clang/Sema/Lookup.h:604

bool empty() const

Description

Return true if no decls were found

Declared at: clang/include/clang/Sema/Lookup.h:339

clang::LookupResult::iterator end() const

Declared at: clang/include/clang/Sema/Lookup.h:336

clang::NamedDecl* getAcceptableDecl(
    clang::NamedDecl* D) const

Description

Retrieve the accepted (re)declaration of the given declaration, if there is one.

Declared at: clang/include/clang/Sema/Lookup.h:385

Parameters

clang::NamedDecl* D

clang::NamedDecl* getAcceptableDeclSlow(
    clang::NamedDecl* D) const

Declared at: clang/include/clang/Sema/Lookup.h:399

Parameters

clang::NamedDecl* D

clang::LookupResult::AmbiguityKind
getAmbiguityKind() const

Declared at: clang/include/clang/Sema/Lookup.h:326

template <class DeclClass>
DeclClass* getAsSingle() const

Declared at: clang/include/clang/Sema/Lookup.h:533

Templates

DeclClass

clang::QualType getBaseObjectType() const

Description

Returns the base object type associated with this lookup; important for [class.protected]. Most lookups do not have an associated base object.

Declared at: clang/include/clang/Sema/Lookup.h:441

clang::CXXBasePaths* getBasePaths() const

Description

Return the base paths structure that's associated with these results, or null if none is.

Declared at: clang/include/clang/Sema/Lookup.h:343

clang::SourceRange getContextRange() const

Description

Gets the source range of the context of this name; for C++ qualified lookups, this is the source range of the scope specifier.

Declared at: clang/include/clang/Sema/Lookup.h:626

clang::NamedDecl* getFoundDecl() const

Description

Fetch the unique decl found by this lookup. Asserts that one was found. This is intended for users who have examined the result kind and are certain that there is only one result.

Declared at: clang/include/clang/Sema/Lookup.h:543

unsigned int getIdentifierNamespace() const

Description

Returns the identifier namespace mask for this lookup.

Declared at: clang/include/clang/Sema/Lookup.h:403

Sema::LookupNameKind getLookupKind() const

Description

Gets the kind of lookup to perform.

Declared at: clang/include/clang/Sema/Lookup.h:253

clang::DeclarationName getLookupName() const

Description

Gets the name to look up.

Declared at: clang/include/clang/Sema/Lookup.h:243

const clang::DeclarationNameInfo&
getLookupNameInfo() const

Description

Gets the name info to look up.

Declared at: clang/include/clang/Sema/Lookup.h:233

clang::SourceLocation getNameLoc() const

Description

Gets the location of the identifier. This isn't always defined: sometimes we're doing lookups on synthesized names.

Declared at: clang/include/clang/Sema/Lookup.h:632

clang::CXXRecordDecl* getNamingClass() const

Description

Returns the 'naming class' for this lookup, i.e. the class which was looked into to find these results. C++0x [class.access.base]p5: The access to a member is affected by the class in which the member is named. This naming class is the class in which the member name was looked up and found. [Note: this class can be explicit, e.g., when a qualified-id is used, or implicit, e.g., when a class member access operator (5.2.5) is used (including cases where an implicit "this->" is added). If both a class member access operator and a qualified-id are used to name the member (as in p->T::m), the class naming the member is the class named by the nested-name-specifier of the qualified-id (that is, T). -- end note ] This is set by the lookup routines when they find results in a class.

Declared at: clang/include/clang/Sema/Lookup.h:429

clang::NamedDecl* getRepresentativeDecl() const

Description

Fetches a representative decl. Useful for lazy diagnostics.

Declared at: clang/include/clang/Sema/Lookup.h:550

clang::LookupResult::LookupResultKind
getResultKind() const

Declared at: clang/include/clang/Sema/Lookup.h:321

clang::Sema& getSema() const

Description

Get the Sema object that this lookup result is searching with.

Declared at: clang/include/clang/Sema/Lookup.h:638

static bool isAcceptable(
    clang::Sema& SemaRef,
    clang::NamedDecl* D,
    Sema::AcceptableKind Kind)

Declared at: clang/include/clang/Sema/Lookup.h:353

Parameters

clang::Sema& SemaRef
clang::NamedDecl* D
Sema::AcceptableKind Kind

static bool isAcceptableSlow(
    clang::Sema& SemaRef,
    clang::NamedDecl* D,
    Sema::AcceptableKind Kind)

Declared at: clang/include/clang/Sema/Lookup.h:396

Parameters

clang::Sema& SemaRef
clang::NamedDecl* D
Sema::AcceptableKind Kind

bool isAmbiguous() const

Declared at: clang/include/clang/Sema/Lookup.h:301

static bool isAvailableForLookup(
    clang::Sema& SemaRef,
    clang::NamedDecl* ND)

Description

Determine whether this lookup is permitted to see the declaration. Note that a reachable but not visible declaration inhabiting a namespace is not allowed to be seen during name lookup. For example: ``` // m.cppm export module m; struct reachable { int v; } export auto func() { return reachable{43}; } // Use.cpp import m; auto Use() { // Not valid. We couldn't see reachable here. // So isAvailableForLookup would return false when we look up 'reachable' here. // return reachable(43).v; // Valid. The field name 'v' is allowed during name lookup. // So isAvailableForLookup would return true when we look up 'v' here. return func().v; } ```

Declared at: clang/include/clang/Sema/Lookup.h:381

Parameters

clang::Sema& SemaRef
clang::NamedDecl* ND

bool isClassLookup() const

Description

Returns whether these results arose from performing a lookup into a class.

Declared at: clang/include/clang/Sema/Lookup.h:409

bool isForExternalRedeclaration() const

Description

True if this lookup is just looking for an existing declaration to link against a declaration with external linkage.

Declared at: clang/include/clang/Sema/Lookup.h:264

bool isForRedeclaration() const

Description

True if this lookup is just looking for an existing declaration.

Declared at: clang/include/clang/Sema/Lookup.h:258

bool isHiddenDeclarationVisible(
    clang::NamedDecl* ND) const

Description

Determine whether this lookup is permitted to see hidden declarations, such as those in modules that have not yet been imported.

Declared at: clang/include/clang/Sema/Lookup.h:281

Parameters

clang::NamedDecl* ND

bool isOverloadedResult() const

Description

Determines if the results are overloaded.

Declared at: clang/include/clang/Sema/Lookup.h:313

static bool isReachable(clang::Sema& SemaRef,
                        clang::NamedDecl* D)

Declared at: clang/include/clang/Sema/Lookup.h:351

Parameters

clang::Sema& SemaRef
clang::NamedDecl* D

static bool isReachableSlow(clang::Sema& SemaRef,
                            clang::NamedDecl* D)

Declared at: clang/include/clang/Sema/Lookup.h:398

Parameters

clang::Sema& SemaRef
clang::NamedDecl* D

bool isShadowed() const

Description

Determine whether the lookup result was shadowed by some other declaration that lookup ignored.

Declared at: clang/include/clang/Sema/Lookup.h:485

bool isSingleResult() const

Description

Determines if this names a single result which is not an unresolved value using decl. If so, it is safe to call getFoundDecl().

Declared at: clang/include/clang/Sema/Lookup.h:308

bool isSingleTagDecl() const

Description

Asks if the result is a single tag decl.

Declared at: clang/include/clang/Sema/Lookup.h:556

bool isSuppressingDiagnostics() const

Description

Determines whether this lookup is suppressing diagnostics.

Declared at: clang/include/clang/Sema/Lookup.h:614

bool isTemplateNameLookup() const

Declared at: clang/include/clang/Sema/Lookup.h:299

bool isUnresolvableResult() const

Declared at: clang/include/clang/Sema/Lookup.h:317

static bool isVisible(clang::Sema& SemaRef,
                      clang::NamedDecl* D)

Description

Determine whether the given declaration is visible to the program.

Declared at: clang/include/clang/Sema/Lookup.h:349

Parameters

clang::Sema& SemaRef
clang::NamedDecl* D

clang::LookupResult::Filter makeFilter()

Description

Create a filter for this result set.

Declared at: clang/include/clang/Sema/Lookup.h:708

void print(llvm::raw_ostream&)

Declared at: clang/include/clang/Sema/Lookup.h:605

Parameters

llvm::raw_ostream&

Sema::RedeclarationKind redeclarationKind() const

Declared at: clang/include/clang/Sema/Lookup.h:268

void resolveKind()

Description

Resolves the result kind of the lookup, possibly hiding decls. This should be called in any environment where lookup might generate multiple lookup results.

Declared at: clang/include/clang/Sema/Lookup.h:496

void resolveKindAfterFilter()

Description

Re-resolves the result kind of the lookup after a set of removals has been performed.

Declared at: clang/include/clang/Sema/Lookup.h:500

void setAllowHidden(bool AH)

Description

Specify whether hidden declarations are visible, e.g., for recovery reasons.

Declared at: clang/include/clang/Sema/Lookup.h:275

Parameters

bool AH

void setAmbiguous(
    clang::LookupResult::AmbiguityKind AK)

Declared at: clang/include/clang/Sema/Lookup.h:727

Parameters

clang::LookupResult::AmbiguityKind AK

void setAmbiguousBaseSubobjectTypes(
    clang::CXXBasePaths& P)

Description

Make these results show that the name was found in base classes of different types. The given paths object is copied and invalidated.

Declared at: clang/include/clang/Sema/Lookup.h:564

Parameters

clang::CXXBasePaths& P

void setAmbiguousBaseSubobjects(
    clang::CXXBasePaths& P)

Description

Make these results show that the name was found in distinct base classes of the same type. The given paths object is copied and invalidated.

Declared at: clang/include/clang/Sema/Lookup.h:570

Parameters

clang::CXXBasePaths& P

void setAmbiguousQualifiedTagHiding()

Description

Make these results show that the name was found in different contexts and a tag decl was hidden by an ordinary decl in a different context.

Declared at: clang/include/clang/Sema/Lookup.h:575

void setBaseObjectType(clang::QualType T)

Description

Sets the base object type for this lookup.

Declared at: clang/include/clang/Sema/Lookup.h:446

Parameters

clang::QualType T

void setContextRange(clang::SourceRange SR)

Description

Sets a 'context' source range.

Declared at: clang/include/clang/Sema/Lookup.h:619

Parameters

clang::SourceRange SR

void setFindLocalExtern(bool FindLocalExtern)

Declared at: clang/include/clang/Sema/Lookup.h:712

Parameters

bool FindLocalExtern

void setHideTags(bool Hide)

Description

Sets whether tag declarations should be hidden by non-tag declarations during resolution. The default is true.

Declared at: clang/include/clang/Sema/Lookup.h:288

Parameters

bool Hide

void setLookupName(clang::DeclarationName Name)

Description

Sets the name to look up.

Declared at: clang/include/clang/Sema/Lookup.h:248

Parameters

clang::DeclarationName Name

void setLookupNameInfo(
    const clang::DeclarationNameInfo& NameInfo)

Description

Sets the name info to look up.

Declared at: clang/include/clang/Sema/Lookup.h:238

Parameters

const clang::DeclarationNameInfo& NameInfo

void setNamingClass(clang::CXXRecordDecl* Record)

Description

Sets the 'naming class' for this lookup.

Declared at: clang/include/clang/Sema/Lookup.h:434

Parameters

clang::CXXRecordDecl* Record

void setNotFoundInCurrentInstantiation()

Description

Note that while no result was found in the current instantiation, there were dependent base classes that could not be searched.

Declared at: clang/include/clang/Sema/Lookup.h:478

void setRedeclarationKind(
    Sema::RedeclarationKind RK)

Description

Change this lookup's redeclaration kind.

Declared at: clang/include/clang/Sema/Lookup.h:598

Parameters

Sema::RedeclarationKind RK

void setShadowed()

Description

Note that we found and ignored a declaration while performing lookup.

Declared at: clang/include/clang/Sema/Lookup.h:489

void setTemplateNameLookup(bool TemplateName)

Description

Sets whether this is a template-name lookup. For template-name lookups, injected-class-names are treated as naming a template rather than a template specialization.

Declared at: clang/include/clang/Sema/Lookup.h:295

Parameters

bool TemplateName

void suppressDiagnostics()

Description

Suppress the diagnostics that would normally fire because of this lookup. This happens during (e.g.) redeclaration lookups.

Declared at: clang/include/clang/Sema/Lookup.h:609

bool wasNotFoundInCurrentInstantiation() const

Description

Determine whether no result was found because we could not search into dependent base classes of the current instantiation.

Declared at: clang/include/clang/Sema/Lookup.h:472

~LookupResult()

Declared at: clang/include/clang/Sema/Lookup.h:227