clang 19.0.0git
Typedefs | Enumerations | Functions
SemaExprMember.cpp File Reference
#include "clang/Sema/Overload.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"

Go to the source code of this file.

Typedefs

typedef llvm::SmallPtrSet< const CXXRecordDecl *, 4 > BaseSet
 

Enumerations

enum  IMAKind {
  IMA_Static , IMA_Mixed , IMA_Mixed_StaticOrExplicitContext , IMA_Mixed_Unrelated ,
  IMA_Instance , IMA_Unresolved , IMA_Abstract , IMA_Unresolved_StaticOrExplicitContext ,
  IMA_Field_Uneval_Context , IMA_Error_StaticOrExplicitContext , IMA_Error_Unrelated
}
 

Functions

static bool isProvablyNotDerivedFrom (Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)
 Determines if the given class is provably not derived from all of the prospective base classes.
 
static IMAKind ClassifyImplicitMemberAccess (Sema &SemaRef, const LookupResult &R)
 The given lookup names class member(s) and is not being used for an address-of-member expression.
 
static void diagnoseInstanceReference (Sema &SemaRef, const CXXScopeSpec &SS, NamedDecl *Rep, const DeclarationNameInfo &nameInfo)
 Diagnose a reference to a field with no object available.
 
static bool IsRGBA (char c)
 Determine whether input char is from rgba component set.
 
static bool IsValidOpenCLComponentSwizzleLength (unsigned len)
 
static QualType CheckExtVectorComponent (Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)
 Check an ext-vector component access expression.
 
static DeclFindGetterSetterNameDeclFromProtocolList (const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
 
static DeclFindGetterSetterNameDecl (const ObjCObjectPointerType *QIdTy, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
 
static void DiagnoseQualifiedMemberReference (Sema &SemaRef, Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, NamedDecl *rep, const DeclarationNameInfo &nameInfo)
 We know that the given qualified member reference points only to declarations which do not belong to the static type of the base expression.
 
static bool LookupMemberExprInRecord (Sema &SemaRef, LookupResult &R, Expr *BaseExpr, const RecordType *RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, SourceLocation TemplateKWLoc, TypoExpr *&TE)
 
static ExprResult LookupMemberExpr (Sema &S, LookupResult &R, ExprResult &BaseExpr, bool &IsArrow, SourceLocation OpLoc, CXXScopeSpec &SS, Decl *ObjCImpDecl, bool HasTemplateArgs, SourceLocation TemplateKWLoc)
 Look up the given member of the given non-type-dependent expression.
 
static ExprResult BuildMSPropertyRefExpr (Sema &S, Expr *BaseExpr, bool IsArrow, const CXXScopeSpec &SS, MSPropertyDecl *PD, const DeclarationNameInfo &NameInfo)
 
static bool IsInFnTryBlockHandler (const Scope *S)
 Determine if the given scope is within a function-try-block handler.
 
static bool ShouldTryAgainWithRedefinitionType (Sema &S, ExprResult &base)
 Given that normal member access failed on the given expression, and given that the expression's type involves builtin-id or builtin-Class, decide whether substituting in the redefinition types would be profitable.
 
static bool isRecordType (QualType T)
 
static bool isPointerToRecordType (QualType T)
 

Typedef Documentation

◆ BaseSet

Definition at line 28 of file SemaExprMember.cpp.

Enumeration Type Documentation

◆ IMAKind

enum IMAKind
Enumerator
IMA_Static 

The reference is definitely not an instance member access.

IMA_Mixed 

The reference may be an implicit instance member access.

IMA_Mixed_StaticOrExplicitContext 

The reference may be to an instance member, but it might be invalid if so, because the context is not an instance method.

IMA_Mixed_Unrelated 

The reference may be to an instance member, but it is invalid if so, because the context is from an unrelated class.

IMA_Instance 

The reference is definitely an implicit instance member access.

IMA_Unresolved 

The reference may be to an unresolved using declaration.

IMA_Abstract 

The reference is a contextually-permitted abstract member reference.

IMA_Unresolved_StaticOrExplicitContext 

The reference may be to an unresolved using declaration and the context is not an instance method.

IMA_Field_Uneval_Context 
IMA_Error_StaticOrExplicitContext 

All possible referrents are instance members and the current context is not an instance method.

IMA_Error_Unrelated 

All possible referrents are instance members of an unrelated class.

Definition at line 40 of file SemaExprMember.cpp.

Function Documentation

◆ BuildMSPropertyRefExpr()

static ExprResult BuildMSPropertyRefExpr ( Sema S,
Expr BaseExpr,
bool  IsArrow,
const CXXScopeSpec SS,
MSPropertyDecl PD,
const DeclarationNameInfo NameInfo 
)
static

◆ CheckExtVectorComponent()

static QualType CheckExtVectorComponent ( Sema S,
QualType  baseType,
ExprValueKind VK,
SourceLocation  OpLoc,
const IdentifierInfo CompName,
SourceLocation  CompLoc 
)
static

◆ ClassifyImplicitMemberAccess()

static IMAKind ClassifyImplicitMemberAccess ( Sema SemaRef,
const LookupResult R 
)
static

The given lookup names class member(s) and is not being used for an address-of-member expression.

Classify the type of access according to whether it's possible that this reference names an instance member. This is best-effort in dependent contexts; it is okay to conservatively answer "yes", in which case some errors will simply not be caught until template-instantiation.

Definition at line 88 of file SemaExprMember.cpp.

References clang::LookupResult::begin(), clang::Sema::CXXThisTypeOverride, clang::LookupResult::empty(), clang::Sema::ExprEvalContexts, clang::CXXRecordDecl::getCanonicalDecl(), clang::Sema::getFunctionLevelDeclContext(), clang::Sema::getLangOpts(), clang::LookupResult::getNamingClass(), clang::DeclContext::getParent(), IMA_Abstract, IMA_Error_StaticOrExplicitContext, IMA_Error_Unrelated, IMA_Field_Uneval_Context, IMA_Instance, IMA_Mixed, IMA_Mixed_StaticOrExplicitContext, IMA_Mixed_Unrelated, IMA_Static, IMA_Unresolved, IMA_Unresolved_StaticOrExplicitContext, clang::QualType::isNull(), isProvablyNotDerivedFrom(), and clang::LookupResult::isUnresolvableResult().

Referenced by clang::Sema::BuildPossibleImplicitMemberExpr().

◆ diagnoseInstanceReference()

static void diagnoseInstanceReference ( Sema SemaRef,
const CXXScopeSpec SS,
NamedDecl Rep,
const DeclarationNameInfo nameInfo 
)
static

◆ DiagnoseQualifiedMemberReference()

static void DiagnoseQualifiedMemberReference ( Sema SemaRef,
Expr BaseExpr,
QualType  BaseType,
const CXXScopeSpec SS,
NamedDecl rep,
const DeclarationNameInfo nameInfo 
)
static

We know that the given qualified member reference points only to declarations which do not belong to the static type of the base expression.

Diagnose the problem.

Definition at line 557 of file SemaExprMember.cpp.

References clang::Sema::Diag(), diagnoseInstanceReference(), clang::DeclarationNameInfo::getLoc(), and clang::CXXScopeSpec::getRange().

Referenced by clang::Sema::CheckQualifiedMemberReference().

◆ FindGetterSetterNameDecl()

static Decl * FindGetterSetterNameDecl ( const ObjCObjectPointerType QIdTy,
IdentifierInfo Member,
const Selector Sel,
ASTContext Context 
)
static

◆ FindGetterSetterNameDeclFromProtocolList()

static Decl * FindGetterSetterNameDeclFromProtocolList ( const ObjCProtocolDecl PDecl,
IdentifierInfo Member,
const Selector Sel,
ASTContext Context 
)
static

◆ IsInFnTryBlockHandler()

static bool IsInFnTryBlockHandler ( const Scope S)
static

Determine if the given scope is within a function-try-block handler.

Definition at line 971 of file SemaExprMember.cpp.

References clang::Scope::TryScope.

Referenced by clang::Sema::BuildMemberReferenceExpr().

◆ isPointerToRecordType()

static bool isPointerToRecordType ( QualType  T)
static

Definition at line 1252 of file SemaExprMember.cpp.

References clang::Type::getAs().

Referenced by LookupMemberExpr().

◆ isProvablyNotDerivedFrom()

static bool isProvablyNotDerivedFrom ( Sema SemaRef,
CXXRecordDecl Record,
const BaseSet Bases 
)
static

Determines if the given class is provably not derived from all of the prospective base classes.

Definition at line 32 of file SemaExprMember.cpp.

Referenced by clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckUsingShadowDecl(), and ClassifyImplicitMemberAccess().

◆ isRecordType()

static bool isRecordType ( QualType  T)
static

◆ IsRGBA()

static bool IsRGBA ( char  c)
static

Determine whether input char is from rgba component set.

Definition at line 305 of file SemaExprMember.cpp.

References c.

Referenced by CheckExtVectorComponent().

◆ IsValidOpenCLComponentSwizzleLength()

static bool IsValidOpenCLComponentSwizzleLength ( unsigned  len)
static

Definition at line 320 of file SemaExprMember.cpp.

Referenced by CheckExtVectorComponent().

◆ LookupMemberExpr()

static ExprResult LookupMemberExpr ( Sema S,
LookupResult R,
ExprResult BaseExpr,
bool IsArrow,
SourceLocation  OpLoc,
CXXScopeSpec SS,
Decl ObjCImpDecl,
bool  HasTemplateArgs,
SourceLocation  TemplateKWLoc 
)
static

Look up the given member of the given non-type-dependent expression.

This can return in one of two ways:

  • If it returns a sentinel null-but-valid result, the caller will assume that lookup was performed and the results written into the provided structure. It will take over from there.
  • Otherwise, the returned expression will be produced in place of an ordinary member expression.

The ObjCImpDecl bit is a gross hack that will need to be properly fixed for ObjC++.

Definition at line 1277 of file SemaExprMember.cpp.

References Category, CheckExtVectorComponent(), clang::CXXScopeSpec::clear(), clang::SelectorTable::constructSetterSelector(), clang::Sema::Context, clang::Sema::CorrectTypo(), clang::ImplicitCastExpr::Create(), clang::FixItHint::CreateRemoval(), clang::FixItHint::CreateReplacement(), clang::Sema::CTK_ErrorRecovery, clang::DeclarationName::CXXDestructorName, clang::declaresSameEntity(), clang::Sema::DefaultFunctionArrayConversion(), clang::Sema::DefaultLvalueConversion(), clang::Sema::Diag(), clang::Sema::diagnoseTypo(), clang::Sema::DiagnoseUseOfDecl(), clang::Sema::DiagRuntimeBehavior(), clang::Sema::Diags, clang::ExprError(), FindGetterSetterNameDecl(), clang::ObjCContainerDecl::FindPropertyDeclaration(), clang::ActionResult< PtrTy, Compress >::get(), clang::ObjCIvarDecl::getAccessControl(), clang::Type::getAs(), clang::DeclarationName::getAsIdentifierInfo(), clang::SourceRange::getBegin(), clang::ASTContext::getCanonicalType(), clang::ObjCMethodDecl::getClassInterface(), clang::Sema::getCurFunction(), clang::Sema::getCurFunctionDecl(), clang::Sema::getCurMethodDecl(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::ASTContext::getExtVectorType(), clang::Preprocessor::getIdentifierTable(), clang::Sema::getLangOpts(), clang::LookupResult::getLookupName(), clang::LookupResult::getLookupNameInfo(), clang::DeclarationName::getNameKind(), clang::LookupResult::getNameLoc(), clang::SelectorTable::getNullarySelector(), clang::ASTContext::getObjCClassType(), clang::QualType::getObjCLifetime(), clang::ASTContext::getObjCSelRedefinitionType(), clang::ObjCObjectPointerType::getObjectType(), clang::Type::getPointeeType(), clang::ASTContext::getPointerType(), clang::ASTContext::getQualifiedType(), clang::CanQual< T >::getQualifiers(), clang::CXXScopeSpec::getRange(), clang::CXXScopeSpec::getScopeRep(), clang::Preprocessor::getSelectorTable(), clang::Stmt::getSourceRange(), clang::ValueDecl::getType(), clang::Expr::getType(), clang::ObjCIvarDecl::getUsageType(), clang::Expr::getValueKind(), clang::Sema::HandleExprPropertyRefExpr(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreParenCasts(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::ImpCastExprToType(), int, clang::Interface, clang::Type::isDependentType(), clang::CXXScopeSpec::isEmpty(), clang::Type::isExtVectorBoolType(), clang::Type::isExtVectorType(), clang::Type::isFunctionType(), clang::DiagnosticsEngine::isIgnored(), clang::CXXScopeSpec::isInvalid(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Decl::isInvalidDecl(), clang::QualType::isNull(), clang::ObjCObjectType::isObjCClass(), clang::ObjCObjectType::isObjCId(), clang::CorrectionCandidateCallback::IsObjCIvarLookup, clang::Type::isObjCSelType(), isPointerToRecordType(), clang::Type::isRecordType(), isRecordType(), clang::Type::isScalarType(), clang::Sema::isSFINAEContext(), clang::Type::isSpecificBuiltinType(), clang::ObjCInterfaceDecl::isSuperClassOf(), clang::Sema::isUnevaluatedContext(), clang::Sema::IvarBacksCurrentMethodAccessor(), clang::ObjCInterfaceDecl::lookupClassMethod(), clang::ObjCInterfaceDecl::lookupInstanceVariable(), LookupMemberExpr(), LookupMemberExprInRecord(), clang::Sema::LookupMemberName, clang::ObjCInterfaceDecl::lookupPrivateMethod(), clang::Member, clang::OBJC_PR_query_instance, clang::Qualifiers::OCL_Weak, clang::OK_ObjCProperty, clang::OMF_dealloc, clang::OMF_finalize, clang::OMF_init, clang::ObjCIvarDecl::Package, clang::Sema::PDiag(), clang::Sema::PerformMemberExprBaseConversion(), clang::Sema::PP, clang::ObjCIvarDecl::Private, clang::ASTContext::PseudoObjectTy, clang::ObjCIvarDecl::Public, clang::sema::FunctionScopeInfo::recordUseOfWeak(), clang::Sema::RequireCompleteType(), clang::Result, ShouldTryAgainWithRedefinitionType(), clang::Sema::tryToRecoverWithCall(), and clang::VK_LValue.

Referenced by clang::Sema::BuildMemberReferenceExpr(), and LookupMemberExpr().

◆ LookupMemberExprInRecord()

static bool LookupMemberExprInRecord ( Sema SemaRef,
LookupResult R,
Expr BaseExpr,
const RecordType RTy,
SourceLocation  OpLoc,
bool  IsArrow,
CXXScopeSpec SS,
bool  HasTemplateArgs,
SourceLocation  TemplateKWLoc,
TypoExpr *&  TE 
)
static

◆ ShouldTryAgainWithRedefinitionType()

static bool ShouldTryAgainWithRedefinitionType ( Sema S,
ExprResult base 
)
static

Given that normal member access failed on the given expression, and given that the expression's type involves builtin-id or builtin-Class, decide whether substituting in the redefinition types would be profitable.

The redefinition type is whatever this translation unit tried to typedef to id/Class; we store it to the side and then re-use it in places like this.

Definition at line 1223 of file SemaExprMember.cpp.

References clang::Sema::Context, clang::ActionResult< PtrTy, Compress >::get(), clang::Type::getAs(), clang::ObjCObjectType::getInterface(), clang::ASTContext::getObjCClassRedefinitionType(), clang::ASTContext::getObjCIdRedefinitionType(), clang::ObjCObjectPointerType::getObjectType(), clang::Expr::getType(), clang::Sema::ImpCastExprToType(), clang::ObjCObjectType::isObjCClass(), and clang::ObjCObjectType::isObjCId().

Referenced by LookupMemberExpr().