зеркало из https://github.com/microsoft/clang-1.git
Lift the ObjCPropertyCallback out of local scope to unbreak VS2005 builds.
Make it an inner class of Parser to assuage access control. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90491 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
c013118155
Коммит
d001454000
|
@ -1087,6 +1087,7 @@ private:
|
|||
private:
|
||||
virtual void _anchor();
|
||||
};
|
||||
struct ObjCPropertyCallback;
|
||||
|
||||
void ParseStructDeclaration(DeclSpec &DS, FieldCallback &Callback);
|
||||
|
||||
|
|
|
@ -228,6 +228,63 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
|
|||
return ClsType;
|
||||
}
|
||||
|
||||
/// The Objective-C property callback. This should be defined where
|
||||
/// it's used, but instead it's been lifted to here to support VS2005.
|
||||
struct Parser::ObjCPropertyCallback : FieldCallback {
|
||||
Parser &P;
|
||||
DeclPtrTy IDecl;
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Props;
|
||||
ObjCDeclSpec &OCDS;
|
||||
SourceLocation AtLoc;
|
||||
tok::ObjCKeywordKind MethodImplKind;
|
||||
|
||||
ObjCPropertyCallback(Parser &P, DeclPtrTy IDecl,
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Props,
|
||||
ObjCDeclSpec &OCDS, SourceLocation AtLoc,
|
||||
tok::ObjCKeywordKind MethodImplKind) :
|
||||
P(P), IDecl(IDecl), Props(Props), OCDS(OCDS), AtLoc(AtLoc),
|
||||
MethodImplKind(MethodImplKind) {
|
||||
}
|
||||
|
||||
DeclPtrTy invoke(FieldDeclarator &FD) {
|
||||
if (FD.D.getIdentifier() == 0) {
|
||||
P.Diag(AtLoc, diag::err_objc_property_requires_field_name)
|
||||
<< FD.D.getSourceRange();
|
||||
return DeclPtrTy();
|
||||
}
|
||||
if (FD.BitfieldSize) {
|
||||
P.Diag(AtLoc, diag::err_objc_property_bitfield)
|
||||
<< FD.D.getSourceRange();
|
||||
return DeclPtrTy();
|
||||
}
|
||||
|
||||
// Install the property declarator into interfaceDecl.
|
||||
IdentifierInfo *SelName =
|
||||
OCDS.getGetterName() ? OCDS.getGetterName() : FD.D.getIdentifier();
|
||||
|
||||
Selector GetterSel =
|
||||
P.PP.getSelectorTable().getNullarySelector(SelName);
|
||||
IdentifierInfo *SetterName = OCDS.getSetterName();
|
||||
Selector SetterSel;
|
||||
if (SetterName)
|
||||
SetterSel = P.PP.getSelectorTable().getSelector(1, &SetterName);
|
||||
else
|
||||
SetterSel = SelectorTable::constructSetterName(P.PP.getIdentifierTable(),
|
||||
P.PP.getSelectorTable(),
|
||||
FD.D.getIdentifier());
|
||||
bool isOverridingProperty = false;
|
||||
DeclPtrTy Property =
|
||||
P.Actions.ActOnProperty(P.CurScope, AtLoc, FD, OCDS,
|
||||
GetterSel, SetterSel, IDecl,
|
||||
&isOverridingProperty,
|
||||
MethodImplKind);
|
||||
if (!isOverridingProperty)
|
||||
Props.push_back(Property);
|
||||
|
||||
return Property;
|
||||
}
|
||||
};
|
||||
|
||||
/// objc-interface-decl-list:
|
||||
/// empty
|
||||
/// objc-interface-decl-list objc-property-decl [OBJC2]
|
||||
|
@ -329,61 +386,8 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
|
|||
ParseObjCPropertyAttribute(OCDS, interfaceDecl,
|
||||
allMethods.data(), allMethods.size());
|
||||
|
||||
struct ObjCPropertyCallback : FieldCallback {
|
||||
Parser &P;
|
||||
DeclPtrTy IDecl;
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Props;
|
||||
ObjCDeclSpec &OCDS;
|
||||
SourceLocation AtLoc;
|
||||
tok::ObjCKeywordKind MethodImplKind;
|
||||
|
||||
ObjCPropertyCallback(Parser &P, DeclPtrTy IDecl,
|
||||
llvm::SmallVectorImpl<DeclPtrTy> &Props,
|
||||
ObjCDeclSpec &OCDS, SourceLocation AtLoc,
|
||||
tok::ObjCKeywordKind MethodImplKind) :
|
||||
P(P), IDecl(IDecl), Props(Props), OCDS(OCDS), AtLoc(AtLoc),
|
||||
MethodImplKind(MethodImplKind) {
|
||||
}
|
||||
|
||||
DeclPtrTy invoke(FieldDeclarator &FD) {
|
||||
if (FD.D.getIdentifier() == 0) {
|
||||
P.Diag(AtLoc, diag::err_objc_property_requires_field_name)
|
||||
<< FD.D.getSourceRange();
|
||||
return DeclPtrTy();
|
||||
}
|
||||
if (FD.BitfieldSize) {
|
||||
P.Diag(AtLoc, diag::err_objc_property_bitfield)
|
||||
<< FD.D.getSourceRange();
|
||||
return DeclPtrTy();
|
||||
}
|
||||
|
||||
// Install the property declarator into interfaceDecl.
|
||||
IdentifierInfo *SelName =
|
||||
OCDS.getGetterName() ? OCDS.getGetterName() : FD.D.getIdentifier();
|
||||
|
||||
Selector GetterSel =
|
||||
P.PP.getSelectorTable().getNullarySelector(SelName);
|
||||
IdentifierInfo *SetterName = OCDS.getSetterName();
|
||||
Selector SetterSel;
|
||||
if (SetterName)
|
||||
SetterSel = P.PP.getSelectorTable().getSelector(1, &SetterName);
|
||||
else
|
||||
SetterSel = SelectorTable::constructSetterName(P.PP.getIdentifierTable(),
|
||||
P.PP.getSelectorTable(),
|
||||
FD.D.getIdentifier());
|
||||
bool isOverridingProperty = false;
|
||||
DeclPtrTy Property =
|
||||
P.Actions.ActOnProperty(P.CurScope, AtLoc, FD, OCDS,
|
||||
GetterSel, SetterSel, IDecl,
|
||||
&isOverridingProperty,
|
||||
MethodImplKind);
|
||||
if (!isOverridingProperty)
|
||||
Props.push_back(Property);
|
||||
|
||||
return Property;
|
||||
}
|
||||
} Callback(*this, interfaceDecl, allProperties,
|
||||
OCDS, AtLoc, MethodImplKind);
|
||||
ObjCPropertyCallback Callback(*this, interfaceDecl, allProperties,
|
||||
OCDS, AtLoc, MethodImplKind);
|
||||
|
||||
// Parse all the comma separated declarators.
|
||||
DeclSpec DS;
|
||||
|
|
Загрузка…
Ссылка в новой задаче