26 using namespace clang;
29 typedef llvm::SmallPtrSet<const CXXRecordDecl*, 4>
BaseSet;
36 return !Bases.count(
Base->getCanonicalDecl());
38 return BaseIsNotInSet(Record) && Record->
forallBases(BaseIsNotInSet);
91 assert(!R.
empty() && (*R.
begin())->isCXXClassMember());
96 (!isa<CXXMethodDecl>(DC) || cast<CXXMethodDecl>(DC)->isStatic());
102 bool hasNonInstance =
false;
103 bool isField =
false;
107 D = D->getUnderlyingDecl();
109 if (D->isCXXInstanceMember()) {
110 isField |= isa<FieldDecl>(D) || isa<MSPropertyDecl>(D) ||
111 isa<IndirectFieldDecl>(D);
114 Classes.insert(R->getCanonicalDecl());
116 hasNonInstance =
true;
134 assert(!AbstractInstanceResult);
154 if (isStaticContext) {
158 return AbstractInstanceResult ? AbstractInstanceResult
164 contextClass = MD->
getParent()->getCanonicalDecl();
166 contextClass = cast<CXXRecordDecl>(DC);
174 if (R.getNamingClass() &&
181 Classes.insert(R.getNamingClass()->getCanonicalDecl());
189 AbstractInstanceResult ? AbstractInstanceResult :
212 bool InStaticMethod = Method && Method->
isStatic();
213 bool IsField = isa<FieldDecl>(Rep) || isa<IndirectFieldDecl>(Rep);
215 if (IsField && InStaticMethod)
217 SemaRef.
Diag(Loc, diag::err_invalid_member_use_in_static_method)
218 << Range << nameInfo.
getName();
219 else if (ContextClass && RepClass && SS.
isEmpty() && !InStaticMethod &&
220 !RepClass->
Equals(ContextClass) && RepClass->
Encloses(ContextClass))
223 SemaRef.
Diag(Loc, diag::err_nested_non_static_member_use)
224 << IsField << RepClass << nameInfo.
getName() << ContextClass << Range;
226 SemaRef.
Diag(Loc, diag::err_invalid_non_static_member_use)
227 << nameInfo.
getName() << Range;
229 SemaRef.
Diag(Loc, diag::err_member_call_without_object)
242 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs,
true, S);
247 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs,
false,
251 Diag(R.
getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
258 if (TemplateArgs || TemplateKWLoc.
isValid())
259 return BuildTemplateIdExpr(SS, TemplateKWLoc, R,
false, TemplateArgs);
260 return BuildDeclarationNameExpr(SS, R,
false);
269 llvm_unreachable(
"unexpected instance member access kind");
293 bool HalvingSwizzle =
false;
297 bool HexSwizzle = (*compStr ==
's' || *compStr ==
'S') && compStr[1];
299 bool HasRepeated =
false;
300 bool HasIndex[16] = {};
306 if (!strcmp(compStr,
"hi") || !strcmp(compStr,
"lo") ||
307 !strcmp(compStr,
"even") || !strcmp(compStr,
"odd")) {
308 HalvingSwizzle =
true;
309 }
else if (!HexSwizzle &&
312 if (HasIndex[Idx]) HasRepeated =
true;
313 HasIndex[Idx] =
true;
317 if (HexSwizzle) compStr++;
319 if (HasIndex[Idx]) HasRepeated =
true;
320 HasIndex[Idx] =
true;
325 if (!HalvingSwizzle && *compStr) {
328 S.
Diag(OpLoc, diag::err_ext_vector_component_name_illegal)
335 if (!HalvingSwizzle) {
343 S.
Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)
355 unsigned CompSize = HalvingSwizzle ? (vecType->
getNumElements() + 1) / 2
372 if ((*I)->getUnderlyingType() == VT)
403 Decl *GDecl =
nullptr;
404 for (
const auto *
I : QIdTy->
quals()) {
418 for (
const auto *
I : QIdTy->
quals()) {
447 if (PT && (!getLangOpts().ObjC1 ||
449 assert(BaseExpr &&
"cannot happen with implicit member accesses");
450 Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
451 << BaseType << BaseExpr->getSourceRange() << NameInfo.
getSourceRange();
458 isDependentScopeSpecifier(SS));
463 Context, BaseExpr, BaseType, IsArrow, OpLoc,
465 NameInfo, TemplateArgs);
482 SemaRef.
Diag(nameInfo.
getLoc(), diag::err_qualified_member_of_unrelated)
483 << SS.
getRange() << rep << BaseType;
503 cast_or_null<CXXRecordDecl>(computeDeclContext(BaseType));
514 if (!BaseExpr && !(*I)->isCXXInstanceMember())
544 explicit RecordMemberExprValidatorCCC(
const RecordType *RTy)
545 : Record(RTy->getDecl()) {
548 WantTypeSpecifiers =
false;
549 WantExpressionKeywords =
false;
550 WantCXXNamedCasts =
false;
551 WantFunctionLikeCasts =
false;
552 WantRemainingKeywords =
false;
555 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
559 if (!ND || !(isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)))
563 if (Record->containsDecl(ND))
566 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Record)) {
568 for (
const auto &BS : RD->bases()) {
570 dyn_cast_or_null<RecordType>(BS.getType().getTypePtrOrNull())) {
571 if (BSTy->getDecl()->containsDecl(ND))
596 diag::err_typecheck_incomplete_tag,
600 if (HasTemplateArgs) {
621 assert(DC &&
"Cannot handle non-computable dependent contexts in lookup");
623 if (!isa<TypeDecl>(DC)) {
650 llvm::make_unique<RecordMemberExprValidatorCCC>(RTy),
654 "Got a keyword as a correction for a member!");
655 bool DroppedSpecifier =
659 << Typo << DC << DroppedSpecifier
662 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << DC << BaseRange;
666 LookupResult R(Q.SemaRef, Q.NameInfo, Q.LookupKind, Q.Redecl);
675 nullptr, R,
nullptr,
nullptr);
685 Decl *ObjCImpDecl,
bool HasTemplateArgs);
698 (SS.
isSet() && isDependentScopeSpecifier(SS)))
699 return ActOnDependentMemberExpr(Base, BaseType,
701 SS, TemplateKWLoc, FirstQualifierInScope,
702 NameInfo, TemplateArgs);
713 SS, TemplateArgs !=
nullptr, TE))
722 *
this, R, BaseResult, IsArrow, OpLoc, SS,
724 TemplateArgs !=
nullptr);
728 Base = BaseResult.
get();
740 return BuildMemberReferenceExpr(Base, BaseType,
741 OpLoc, IsArrow, SS, TemplateKWLoc,
742 FirstQualifierInScope, R, TemplateArgs, S,
757 Expr *baseObjectExpr,
761 bool baseObjectIsPointer =
false;
775 assert(!baseObjectExpr &&
"anonymous struct/union is static data member?");
780 = BuildDeclarationNameExpr(EmptySS, baseNameInfo, baseVariable);
783 baseObjectExpr = result.
get();
784 baseObjectIsPointer =
false;
789 }
else if (baseObjectExpr) {
796 baseObjectIsPointer =
true;
799 baseObjectIsPointer =
false;
809 QualType ThisTy = getCurrentThisType();
811 Diag(loc, diag::err_invalid_member_use_in_static_method)
817 CheckCXXThisCapture(loc);
820 baseObjectIsPointer =
true;
826 Expr *result = baseObjectExpr;
839 foundDecl, memberNameInfo).
get();
850 FieldDecl *field = cast<FieldDecl>(*FI++);
860 field, fakeFoundDecl, memberNameInfo).
get();
886 assert((!isArrow || Base->
isRValue()) &&
"-> base must be a pointer rvalue");
889 FoundDecl, MemberNameInfo, TemplateArgs, Ty, VK, OK);
914 << 1 << MemberNameInfo.
getName()
917 S.
Diag(VarTempl->getLocation(), diag::note_template_decl_here);
922 VarTempl, TemplateKWLoc, MemberNameInfo.
getLoc(), *TemplateArgs);
941 bool SuppressQualifierCheck,
976 if (!BaseExpr && CurLSI) {
987 if (!CheckCXXThisCapture(Loc,
false,
false))
988 CheckCXXThisCapture(Loc);
989 }
else if (CurContext->isDependentContext()) {
1007 const auto *FD = getCurFunctionDecl();
1008 if (S && BaseExpr && FD &&
1009 (isa<CXXDestructorDecl>(FD) || isa<CXXConstructorDecl>(FD)) &&
1012 Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)
1013 << isa<CXXDestructorDecl>(FD);
1018 ? computeDeclContext(SS,
false)
1023 if (!IsArrow && BaseExpr) {
1026 bool MayBePseudoDestructor =
false;
1027 RetryExpr = ActOnStartCXXMemberReference(getCurScope(), BaseExpr,
1028 OpLoc, tok::arrow, ObjectType,
1029 MayBePseudoDestructor);
1032 RetryExpr = ActOnMemberAccessExpr(
1033 ExtraArgs->
S, RetryExpr.
get(), OpLoc, tok::arrow, TempSS,
1040 Diag(OpLoc, diag::err_no_member_overloaded_arrow)
1048 << (BaseExpr ? BaseExpr->getSourceRange() :
SourceRange());
1059 if ((SS.
isSet() || !BaseExpr ||
1060 (isa<CXXThisExpr>(BaseExpr) &&
1061 cast<CXXThisExpr>(BaseExpr)->isImplicit())) &&
1062 !SuppressQualifierCheck &&
1063 CheckQualifiedMemberReference(BaseExpr, BaseType, SS, R))
1075 BaseExpr, BaseExprType,
1078 TemplateKWLoc, MemberNameInfo,
1093 if (MemberDecl->isInvalidDecl())
1104 assert((!TemplateArgs || isa<VarTemplateDecl>(MemberDecl)) &&
1105 "How did we get template arguments here sans a variable template");
1106 if (isa<VarTemplateDecl>(MemberDecl)) {
1108 *
this, cast<VarTemplateDecl>(MemberDecl), TemplateArgs,
1114 FoundDecl, TemplateArgs);
1119 CheckCXXThisCapture(Loc);
1124 if (DiagnoseUseOfDecl(MemberDecl, MemberLoc))
1127 if (
FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl))
1129 FoundDecl, MemberNameInfo);
1138 return BuildAnonymousStructUnionMemberReference(SS, MemberLoc, FD,
1139 FoundDecl, BaseExpr,
1142 if (
VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
1144 TemplateKWLoc, Var, FoundDecl, MemberNameInfo,
1145 Var->getType().getNonReferenceType(),
VK_LValue,
1149 if (
CXXMethodDecl *MemberFn = dyn_cast<CXXMethodDecl>(MemberDecl)) {
1152 if (MemberFn->isInstance()) {
1157 type = MemberFn->getType();
1161 TemplateKWLoc, MemberFn, FoundDecl, MemberNameInfo,
1164 assert(!isa<FunctionDecl>(MemberDecl) &&
"member function not C++ method?");
1168 TemplateKWLoc, Enum, FoundDecl, MemberNameInfo,
1171 if (
VarTemplateDecl *VarTempl = dyn_cast<VarTemplateDecl>(MemberDecl)) {
1173 *
this, VarTempl, TemplateArgs, MemberNameInfo, TemplateKWLoc))
1175 TemplateKWLoc, Var, FoundDecl, MemberNameInfo,
1176 Var->getType().getNonReferenceType(),
VK_LValue,
1182 if (isa<TypeDecl>(MemberDecl))
1183 Diag(MemberLoc, diag::err_typecheck_member_reference_type)
1184 << MemberName << BaseType << int(IsArrow);
1186 Diag(MemberLoc, diag::err_typecheck_member_reference_unknown)
1187 << MemberName << BaseType << int(IsArrow);
1189 Diag(MemberDecl->getLocation(), diag::note_member_declared_here)
1204 if (!opty)
return false;
1232 return PT->getPointeeType()->isRecordType();
1240 return DefaultFunctionArrayLvalueConversion(Base);
1242 return CheckPlaceholderExpr(Base);
1258 Decl *ObjCImpDecl,
bool HasTemplateArgs) {
1259 assert(BaseExpr.
get() &&
"no base expression");
1263 if (BaseExpr.isInvalid())
1266 QualType BaseType = BaseExpr.get()->getType();
1291 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1292 << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
1299 S.
Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
1300 << BaseType << BaseExpr.get()->getSourceRange();
1309 OpLoc, IsArrow, SS, HasTemplateArgs, TE))
1337 (OTy->isObjCId() || OTy->isObjCClass()))
1342 if (OTy->isObjCId() && Member->
isStr(
"isa"))
1347 ObjCImpDecl, HasTemplateArgs);
1352 diag::err_typecheck_incomplete_tag,
1361 auto Validator = llvm::make_unique<DeclFilterCCC<ObjCIvarDecl>>();
1362 Validator->IsObjCIvarLookup = IsArrow;
1369 S.
PDiag(diag::err_typecheck_member_reference_ivar_suggest)
1373 assert(!ClassDeclared);
1374 Decl *D = cast<Decl>(IV->getDeclContext());
1376 D = CAT->getClassInterface();
1377 ClassDeclared = cast<ObjCInterfaceDecl>(D);
1382 S.
Diag(MemberLoc, diag::err_property_found_suggest)
1383 << Member << BaseExpr.get()->getType()
1388 S.
Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
1390 << BaseExpr.get()->getSourceRange();
1395 assert(ClassDeclared);
1400 if (IV->isInvalidDecl())
1410 ClassOfMethodDecl = MD->getClassInterface();
1419 dyn_cast<ObjCImplementationDecl>(ObjCImpDecl))
1420 ClassOfMethodDecl = IMPD->getClassInterface();
1422 dyn_cast<ObjCCategoryImplDecl>(ObjCImpDecl))
1423 ClassOfMethodDecl = CatImplClass->getClassInterface();
1429 S.
Diag(MemberLoc, diag::error_private_ivar_access)
1433 S.
Diag(MemberLoc, diag::error_protected_ivar_access)
1441 if (UO->getOpcode() == UO_Deref)
1444 if (
DeclRefExpr *DE = dyn_cast<DeclRefExpr>(BaseExp))
1446 S.
Diag(DE->getLocation(), diag::error_arc_weak_ivar_access);
1458 S.
Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->
getDeclName();
1462 IV, IV->
getUsageType(BaseType), MemberLoc, OpLoc, BaseExpr.get(),
1467 if (!S.
Diags.
isIgnored(diag::warn_arc_repeated_use_of_weak, MemberLoc))
1486 if (BaseExpr.isInvalid())
1490 BaseExpr.get()->getType()));
1524 SMD = dyn_cast<ObjCMethodDecl>(SDecl);
1535 ObjCImpDecl, HasTemplateArgs);
1537 return ExprError(S.
Diag(MemberLoc, diag::err_property_not_found)
1538 << MemberName << BaseType);
1548 ObjCImpDecl, HasTemplateArgs);
1579 if (Getter || Setter) {
1587 ObjCImpDecl, HasTemplateArgs);
1589 return ExprError(S.
Diag(MemberLoc, diag::err_property_not_found)
1590 << MemberName << BaseType);
1608 VK = POE->getSyntacticForm()->getValueKind();
1610 VK = BaseExpr.get()->getValueKind();
1628 ObjCImpDecl, HasTemplateArgs);
1642 if (!IsArrow && Ptr->getPointeeType()->isRecordType() &&
1644 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1645 << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
1651 ObjCImpDecl, HasTemplateArgs);
1658 BaseExpr, S.
PDiag(diag::err_member_reference_needs_call),
1661 if (BaseExpr.isInvalid())
1665 ObjCImpDecl, HasTemplateArgs);
1668 S.
Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
1669 << BaseType << BaseExpr.get()->getSourceRange() << MemberLoc;
1690 Decl *ObjCImpDecl) {
1695 if (getLangOpts().MicrosoftExt &&
1698 diag::ext_ms_explicit_constructor_call);
1705 DecomposeUnqualifiedId(Id, TemplateArgsBuffer,
1706 NameInfo, TemplateArgs);
1709 bool IsArrow = (OpKind == tok::arrow);
1712 = (!SS.
isSet() ?
nullptr : FindFirstQualifierInScope(S, SS.
getScopeRep()));
1717 Base = Result.
get();
1720 isDependentScopeSpecifier(SS)) {
1721 return ActOnDependentMemberExpr(Base, Base->
getType(), IsArrow, OpLoc, SS,
1722 TemplateKWLoc, FirstQualifierInScope,
1723 NameInfo, TemplateArgs);
1727 return BuildMemberReferenceExpr(Base, Base->
getType(), OpLoc, IsArrow, SS,
1728 TemplateKWLoc, FirstQualifierInScope,
1729 NameInfo, TemplateArgs,
S, &ExtraArgs);
1776 Qualifiers Combined = BaseQuals + MemberQuals;
1777 if (Combined != MemberQuals)
1791 MemberNameInfo, MemberType, VK, OK);
1813 bool IsKnownInstance,
const Scope *
S) {
1821 QualType ThisTy = getCurrentThisType();
1822 assert(!ThisTy.
isNull() &&
"didn't correctly pre-flight capture of 'this'");
1824 Expr *baseExpr =
nullptr;
1825 if (IsKnownInstance) {
1829 CheckCXXThisCapture(Loc);
1833 return BuildMemberReferenceExpr(baseExpr, ThisTy,
1838 R, TemplateArgs, S);
bool isObjCSelType() const
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
unsigned getNumElements() const
unsigned getFlags() const
getFlags - Return the flags for this scope.
SourceLocation getEnd() const
This is the scope of a C++ try statement.
IdKind getKind() const
Determine what kind of name we have.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
static const Decl * getCanonicalDecl(const Decl *D)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
protocol_range protocols() const
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Smart pointer class that efficiently represents Objective-C method names.
SelectorTable & getSelectorTable()
ArrayRef< NamedDecl * >::const_iterator chain_iterator
PointerType - C99 6.7.5.1 - Pointer Declarators.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
ObjCInterfaceDecl * getClassInterface()
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
The reference may be to an instance member, but it might be invalid if so, because the context is not...
bool isBitField() const
Determines whether this field is a bitfield.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static MemberExpr * BuildMemberExpr(Sema &SemaRef, ASTContext &C, Expr *Base, bool isArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
Build a MemberExpr AST node.
DeclContext * getFunctionLevelDeclContext()
static void diagnoseInstanceReference(Sema &SemaRef, const CXXScopeSpec &SS, NamedDecl *Rep, const DeclarationNameInfo &nameInfo)
Diagnose a reference to a field with no object available.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ActionResult< Expr * > ExprResult
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool isRecordType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Defines the C++ template declaration subclasses.
The reference is definitely an implicit instance member access.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool forallBases(ForallBasesCallback BaseMatches, bool AllowShortCircuit=true) const
Determines if the given callback holds for all the direct or indirect base classes of this type...
Declaration of a variable template.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
static bool IsInFnTryBlockHandler(const Scope *S)
Determine if the given scope is within a function-try-block handler.
This file provides some common utility functions for processing Lambda related AST Constructs...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
DiagnosticsEngine & Diags
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
bool isUnresolvableResult() const
QualType getObjCClassType() const
Represents the Objective-C Class type.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void setBegin(SourceLocation b)
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isEmpty() const
No scope specifier.
iterator begin(Source *source, bool LocalOnly=false)
The collection of all-type qualifiers we support.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
RecordDecl - Represents a struct/union/class.
DeclarationName getName() const
getName - Returns the embedded declaration name.
One of these records is kept for each identifier that is lexed.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
static VarDecl * getVarTemplateSpecialization(Sema &S, VarTemplateDecl *VarTempl, const TemplateArgumentListInfo *TemplateArgs, const DeclarationNameInfo &MemberNameInfo, SourceLocation TemplateKWLoc)
ObjCMethodFamily
A family of Objective-C methods.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
The reference may be to an unresolved using declaration and the context is not an instance method...
The iterator over UnresolvedSets.
static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base)
Given that normal member access failed on the given expression, and given that the expression's type ...
static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, Expr *BaseExpr, const RecordType *RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, TypoExpr *&TE)
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
static int getPointAccessorIdx(char c)
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
Represents a C++ unqualified-id that has been parsed.
Selector getNullarySelector(IdentifierInfo *ID)
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents the results of name lookup.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
A convenient class for passing around template argument information.
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...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
VarDecl * getVarDecl() const
ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())
static bool isRecordType(QualType T)
The reference is a contextually-permitted abstract member reference.
CanQualType PseudoObjectTy
RecordDecl * getDecl() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Scope - A scope is a transient data structure that is used while parsing the program.
chain_iterator chain_begin() const
CXXRecordDecl * getCanonicalDecl() override
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a C++ nested-name-specifier or a global scope specifier.
Represents an Objective-C protocol declaration.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
The reference may be an implicit instance member access.
An ordinary object is located at an address in memory.
Represents an ObjC class declaration.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool isExtVectorType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
detail::InMemoryDirectory::const_iterator I
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
SourceRange getRange() const
Represents the this expression in C++.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > BaseSet
ImplicitCaptureStyle ImpCaptureStyle
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Sema - This implements semantic analysis and AST building for C.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
All possible referrents are instance members and the current context is not an instance method...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
SourceLocation getNameLoc() const
Gets the location of the identifier.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Defines the clang::Preprocessor interface.
All possible referrents are instance members of an unrelated class.
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
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 ...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
A member reference to an MSPropertyDecl.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
QualType getElementType() const
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static bool isPointerToRecordType(QualType T)
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
static ExprResult BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow, const CXXScopeSpec &SS, MSPropertyDecl *PD, const DeclarationNameInfo &NameInfo)
Encodes a location in the source.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
const TemplateArgument * iterator
VarDecl * IsOpenMPCapturedDecl(ValueDecl *D)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
bool isValid() const
Return true if this is a valid SourceLocation object.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
IdentifierTable & getIdentifierTable()
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Represents a static or instance method of a struct/union/class.
ExprResult DefaultLvalueConversion(Expr *E)
The reference may be to an unresolved using declaration.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
ObjCCategoryDecl - Represents a category declaration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Represents one property declaration in an Objective-C interface.
SourceLocation getBegin() const
const T * castAs() const
Member-template castAs<specific type>.
static Decl * FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
void addPotentialThisCapture(SourceLocation Loc)
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool isAccessorWithinNumElements(char c) const
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
QualType getPointeeType() const
const DeclAccessPair & getPair() const
A POD class for pairing a NamedDecl* with an access specifier.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, ExprResult &BaseExpr, bool &IsArrow, SourceLocation OpLoc, CXXScopeSpec &SS, Decl *ObjCImpDecl, bool HasTemplateArgs)
Look up the given member of the given non-type-dependent expression.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
DeclarationName - The name of a declaration.
chain_iterator chain_end() const
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
detail::InMemoryDirectory::const_iterator E
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
The main callback when the parser finds something like expression .
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, bool IsDefiniteInstance, const Scope *S)
Builds an implicit member access expression.
Represents a pointer to an Objective C object.
bool empty() const
Return true if no decls were found.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
const T * getAs() const
Member-template getAs<specific type>'.
ExternalSemaSource * getExternalSource() const
This is the scope for a function-level C++ try or catch scope.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface...
bool isFunctionType() const
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
std::string getAsString(const LangOptions &LO) const
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
A bitfield object is a bitfield on a C or C++ record.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
The reference may be to an instance member, but it is invalid if so, because the context is from an u...
static ExprResult BuildFieldReferenceExpr(Sema &S, Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
AccessControl getAccessControl() const
Reading or writing from this object requires a barrier call.
static UnresolvedMemberExpr * Create(const ASTContext &C, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Represents a C++ struct/union/class.
The current expression occurs within a discarded statement.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
ObjCIvarDecl - Represents an ObjC instance variable.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization)
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isSet() const
Deprecated.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
The reference is definitely not an instance member access.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
An instance of this class represents the declaration of a property member.
An l-value expression is a reference to an object with independent storage.
static Decl * FindGetterSetterNameDeclFromProtocolList(const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
static int getNumericAccessorIdx(char c)
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
NamedDecl - This represents a decl with a name.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static QualType CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)
Check an ext-vector component access expression.
void WillReplaceSpecifier(bool ForceReplacement)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
void clear()
Clears out any current state.
bool isOverloadedResult() const
Determines if the results are overloaded.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
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...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, ExprObjectKind OK, SourceLocation Loc)
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
bool isPointerType() const