本文整理汇总了C++中ObjCInterfaceDecl::lookupInstanceVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjCInterfaceDecl::lookupInstanceVariable方法的具体用法?C++ ObjCInterfaceDecl::lookupInstanceVariable怎么用?C++ ObjCInterfaceDecl::lookupInstanceVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjCInterfaceDecl
的用法示例。
在下文中一共展示了ObjCInterfaceDecl::lookupInstanceVariable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExprError
//.........这里部分代码省略.........
// If this reference is in an @implementation, check for 'private' methods.
if (!Getter)
Getter = IFace->lookupPrivateMethod(Sel);
// Look through local category implementations associated with the class.
if (!Getter)
Getter = IFace->getCategoryInstanceMethod(Sel);
if (Getter) {
// Check if we can reference this property.
if (DiagnoseUseOfDecl(Getter, MemberLoc))
return ExprError();
}
// If we found a getter then this may be a valid dot-reference, we
// will look for the matching setter, in case it is needed.
Selector SetterSel =
SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), Member);
ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
// May be founf in property's qualified list.
if (!Setter)
Setter = LookupMethodInQualifiedType(SetterSel, OPT, true);
if (!Setter) {
// If this reference is in an @implementation, also check for 'private'
// methods.
Setter = IFace->lookupPrivateMethod(SetterSel);
}
// Look through local category implementations associated with the class.
if (!Setter)
Setter = IFace->getCategoryInstanceMethod(SetterSel);
if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
return ExprError();
if (Getter || Setter) {
QualType PType;
if (Getter)
PType = Getter->getSendResultType();
else {
ParmVarDecl *ArgDecl = *Setter->param_begin();
PType = ArgDecl->getType();
}
ExprValueKind VK = VK_LValue;
ExprObjectKind OK = OK_ObjCProperty;
if (!getLangOptions().CPlusPlus && !PType.hasQualifiers() &&
PType->isVoidType())
VK = VK_RValue, OK = OK_Ordinary;
if (Super)
return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter,
PType, VK, OK,
MemberLoc,
SuperLoc, SuperType));
else
return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter,
PType, VK, OK,
MemberLoc, BaseExpr));
}
// Attempt to correct for typos in property names.
LookupResult Res(*this, MemberName, MemberLoc, LookupOrdinaryName);
if (CorrectTypo(Res, 0, 0, IFace, false, CTC_NoKeywords, OPT) &&
Res.getAsSingle<ObjCPropertyDecl>()) {
DeclarationName TypoResult = Res.getLookupName();
Diag(MemberLoc, diag::err_property_not_found_suggest)
<< MemberName << QualType(OPT, 0) << TypoResult
<< FixItHint::CreateReplacement(MemberLoc, TypoResult.getAsString());
ObjCPropertyDecl *Property = Res.getAsSingle<ObjCPropertyDecl>();
Diag(Property->getLocation(), diag::note_previous_decl)
<< Property->getDeclName();
return HandleExprPropertyRefExpr(OPT, BaseExpr, TypoResult, MemberLoc,
SuperLoc, SuperType, Super);
}
ObjCInterfaceDecl *ClassDeclared;
if (ObjCIvarDecl *Ivar =
IFace->lookupInstanceVariable(Member, ClassDeclared)) {
QualType T = Ivar->getType();
if (const ObjCObjectPointerType * OBJPT =
T->getAsObjCInterfacePointerType()) {
const ObjCInterfaceType *IFaceT = OBJPT->getInterfaceType();
if (ObjCInterfaceDecl *IFace = IFaceT->getDecl())
if (IFace->isForwardDecl()) {
Diag(MemberLoc, diag::err_property_not_as_forward_class)
<< MemberName << IFace;
Diag(IFace->getLocation(), diag::note_forward_class);
return ExprError();
}
}
}
Diag(MemberLoc, diag::err_property_not_found)
<< MemberName << QualType(OPT, 0);
if (Setter)
Diag(Setter->getLocation(), diag::note_getter_unavailable)
<< MemberName << BaseExpr->getSourceRange();
return ExprError();
}