clang: lib/Sema/SemaExprMember.cpp File Reference (original) (raw)
Go to the source code of this file.
| 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 Decl * | FindGetterSetterNameDeclFromProtocolList (const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context) |
| static Decl * | FindGetterSetterNameDecl (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, QualType RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, SourceLocation TemplateKWLoc) |
| 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) |
◆ BaseSet
◆ 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_Dependent | Whether the context is static is dependent on the enclosing template (i.e. in a dependent class scope explicit specialization). |
| 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.
◆ BuildMSPropertyRefExpr()
◆ CheckExtVectorComponent()
Check an ext-vector component access expression.
VK should be set in advance to the value kind of the base expression.
Definition at line 372 of file SemaExprMember.cpp.
References clang::LazyVector< T, Source, Loader, LoadedStorage, LocalStorage >::begin(), clang::Type::castAs(), clang::Sema::Context, clang::SemaBase::Diag(), clang::LazyVector< T, Source, Loader, LoadedStorage, LocalStorage >::end(), clang::Sema::ExtVectorDecls, clang::VectorType::getElementType(), clang::Sema::getExternalSource(), clang::ASTContext::getExtVectorType(), clang::Sema::getLangOpts(), clang::IdentifierInfo::getLength(), clang::SourceLocation::getLocWithOffset(), clang::IdentifierInfo::getNameStart(), clang::VectorType::getNumElements(), clang::ExtVectorType::getNumericAccessorIdx(), clang::LangOptions::getOpenCLCompatibleVersion(), clang::ExtVectorType::getPointAccessorIdx(), clang::ASTContext::getTypedefType(), clang::ExtVectorType::isAccessorWithinNumElements(), IsRGBA(), IsValidOpenCLComponentSwizzleLength(), clang::None, and clang::VK_PRValue.
Referenced by LookupMemberExpr().
◆ ClassifyImplicitMemberAccess()
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 92 of file SemaExprMember.cpp.
References clang::LookupResult::begin(), clang::cast(), clang::Sema::ConstantEvaluated, clang::Sema::CXXThisTypeOverride, clang::Sema::DiscardedStatement, clang::LookupResult::empty(), clang::Sema::ExprEvalContexts, clang::CXXRecordDecl::getCanonicalDecl(), clang::Sema::getFunctionLevelDeclContext(), clang::Sema::getLangOpts(), clang::LookupResult::getNamingClass(), clang::DeclContext::getParent(), IMA_Abstract, IMA_Dependent, 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::Sema::ImmediateFunctionContext, clang::isa(), clang::QualType::isNull(), isProvablyNotDerivedFrom(), clang::LookupResult::isUnresolvableResult(), clang::Sema::PotentiallyEvaluated, clang::Sema::PotentiallyEvaluatedIfUsed, clang::Sema::Unevaluated, clang::Sema::UnevaluatedAbstract, and clang::Sema::UnevaluatedList.
Referenced by clang::Sema::BuildPossibleImplicitMemberExpr().
◆ diagnoseInstanceReference()
Diagnose a reference to a field with no object available.
Definition at line 221 of file SemaExprMember.cpp.
References clang::cast(), clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), Diag(), clang::DeclContext::Encloses(), clang::DeclContext::Equals(), clang::DeclarationName::getAsString(), clang::SourceRange::getBegin(), clang::Decl::getDeclContext(), clang::Sema::getFunctionLevelDeclContext(), clang::DeclarationNameInfo::getLoc(), clang::DeclarationNameInfo::getName(), clang::DeclContext::getParent(), clang::CXXScopeSpec::getRange(), clang::NamedDecl::getUnderlyingDecl(), clang::isa(), clang::CXXScopeSpec::isEmpty(), clang::DeclarationName::isEmpty(), and clang::CXXScopeSpec::isSet().
Referenced by clang::Sema::BuildPossibleImplicitMemberExpr(), and DiagnoseQualifiedMemberReference().
◆ DiagnoseQualifiedMemberReference()
◆ FindGetterSetterNameDecl()
◆ FindGetterSetterNameDeclFromProtocolList()
◆ IsInFnTryBlockHandler()
| bool IsInFnTryBlockHandler ( const Scope * S) | static |
|---|
◆ isPointerToRecordType()
◆ isProvablyNotDerivedFrom()
◆ isRecordType()
◆ IsRGBA()
| bool IsRGBA ( char c) | static |
|---|
◆ IsValidOpenCLComponentSwizzleLength()
| bool IsValidOpenCLComponentSwizzleLength ( unsigned len) | static |
|---|
◆ LookupMemberExpr()
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 1225 of file SemaExprMember.cpp.
References clang::cast(), CheckExtVectorComponent(), clang::CXXScopeSpec::clear(), clang::SelectorTable::constructSetterSelector(), clang::Sema::Context, clang::Sema::CorrectTypo(), clang::ImplicitCastExpr::Create(), clang::FixItHint::CreateRemoval(), clang::FixItHint::CreateReplacement(), clang::DeclarationName::CXXDestructorName, clang::declaresSameEntity(), clang::Sema::DefaultFunctionArrayConversion(), clang::Sema::DefaultLvalueConversion(), clang::ASTContext::DependentTy, clang::SemaBase::Diag(), clang::Sema::diagnoseTypo(), clang::Sema::DiagnoseUseOfDecl(), clang::Sema::DiagRuntimeBehavior(), clang::Sema::Diags, clang::ErrorRecovery, clang::ExprEmpty(), 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::ASTContext::getPointerType(), clang::ASTContext::getQualifiedType(), clang::CanQual< T >::getQualifiers(), clang::CXXScopeSpec::getRange(), clang::CXXScopeSpec::getScopeRep(), clang::Preprocessor::getSelectorTable(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::ObjCIvarDecl::getUsageType(), clang::Expr::getValueKind(), clang::SemaObjC::HandleExprPropertyRefExpr(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreParenCasts(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::ImpCastExprToType(), int, clang::Interface, clang::CXXScopeSpec::isEmpty(), clang::DiagnosticsEngine::isIgnored(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::CXXScopeSpec::isInvalid(), clang::Decl::isInvalidDecl(), clang::QualType::isNull(), clang::CorrectionCandidateCallback::IsObjCIvarLookup, clang::Type::isObjCSelType(), isPointerToRecordType(), isRecordType(), clang::Sema::isSFINAEContext(), clang::ObjCInterfaceDecl::isSuperClassOf(), clang::Sema::isUnevaluatedContext(), clang::ObjCInterfaceDecl::lookupClassMethod(), clang::ObjCInterfaceDecl::lookupInstanceVariable(), LookupMemberExpr(), LookupMemberExprInRecord(), clang::Sema::LookupMemberName, clang::ObjCInterfaceDecl::lookupPrivateMethod(), clang::Member, clang::Sema::ObjC(), 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::SemaBase::PDiag(), clang::Sema::PerformMemberExprBaseConversion(), clang::Sema::PP, clang::ObjCIvarDecl::Private, clang::ASTContext::PseudoObjectTy, clang::ObjCIvarDecl::Public, clang::sema::FunctionScopeInfo::recordUseOfWeak(), clang::Sema::RequireCompleteType(), clang::LookupResult::setNotFoundInCurrentInstantiation(), ShouldTryAgainWithRedefinitionType(), clang::Sema::tryToRecoverWithCall(), and clang::VK_LValue.
Referenced by clang::Sema::BuildMemberReferenceExpr(), and LookupMemberExpr().
◆ LookupMemberExprInRecord()
◆ ShouldTryAgainWithRedefinitionType()
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 1172 of file SemaExprMember.cpp.
References clang::Sema::Context, clang::ActionResult< PtrTy, Compress >::get(), clang::Type::getAs(), clang::ASTContext::getObjCClassRedefinitionType(), clang::ASTContext::getObjCIdRedefinitionType(), clang::ObjCObjectPointerType::getObjectType(), clang::Expr::getType(), and clang::Sema::ImpCastExprToType().
Referenced by LookupMemberExpr().