int NumIvars = CDecl->getIntfDeclNumIvars();
// If no ivars and no root or if its root, directly or indirectly,
- // have no ivars (thus not synthesize)
- // then no need to synthesize this class either.
+ // have no ivars (thus not synthesized) then no need to synthesize this class.
if (NumIvars <= 0 && (!RCDecl || !ObjcSynthesizedStructs.count(RCDecl)))
return;
/// objc-type-qualifier
/// objc-type-qualifiers objc-type-qualifier
///
-Parser::TypeTy *Parser::ParseObjCTypeName() {
+Parser::TypeTy *Parser::ParseObjCTypeName(ObjcDeclSpec &DS) {
assert(Tok.is(tok::l_paren) && "expected (");
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
TypeTy *Ty = 0;
// Parse type qualifiers, in, inout, etc.
- ObjcDeclSpec DS;
ParseObjcTypeQualifierList(DS);
if (isTypeSpecifierQualifier()) {
{
// Parse the return type.
TypeTy *ReturnType = 0;
+ ObjcDeclSpec DSRet;
if (Tok.is(tok::l_paren))
- ReturnType = ParseObjCTypeName();
+ ReturnType = ParseObjCTypeName(DSRet);
SourceLocation selLoc;
IdentifierInfo *SelIdent = ParseObjCSelector(selLoc);
if (Tok.isNot(tok::colon)) {
Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
- mType, ReturnType, Sel,
- 0, 0, MethodAttrs, MethodImplKind);
+ mType, DSRet, ReturnType, Sel,
+ 0, 0, 0, MethodAttrs, MethodImplKind);
}
llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
llvm::SmallVector<Action::TypeTy *, 12> KeyTypes;
+ llvm::SmallVector<ObjcDeclSpec, 12> ArgTypeQuals;
llvm::SmallVector<IdentifierInfo *, 12> ArgNames;
Action::TypeTy *TypeInfo;
break;
}
ConsumeToken(); // Eat the ':'.
- if (Tok.is(tok::l_paren)) // Parse the argument type.
- TypeInfo = ParseObjCTypeName();
+ ObjcDeclSpec DSType;
+ if (Tok.is(tok::l_paren)) { // Parse the argument type.
+ TypeInfo = ParseObjCTypeName(DSType);
+ }
else
TypeInfo = 0;
KeyTypes.push_back(TypeInfo);
+ ArgTypeQuals.push_back(DSType);
// If attributes exist before the argument name, parse them.
if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
&KeyIdents[0]);
return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
- mType, ReturnType, Sel,
- &KeyTypes[0], &ArgNames[0],
+ mType, DSRet, ReturnType, Sel,
+ &ArgTypeQuals[0], &KeyTypes[0],
+ &ArgNames[0],
MethodAttrs, MethodImplKind);
}
virtual DeclTy *ActOnMethodDeclaration(
SourceLocation BeginLoc, // location of the + or -.
SourceLocation EndLoc, // location of the ; or {.
- tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel,
+ tok::TokenKind MethodType, ObjcDeclSpec &ReturnQT, TypeTy *ReturnType,
+ Selector Sel,
// optional arguments. The number of types/arguments is obtained
// from the Sel.getNumArgs().
- TypeTy **ArgTypes, IdentifierInfo **ArgNames,
+ ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind);
// ActOnClassMessage - used for both unary and keyword messages.
IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace);
return;
}
+ // If implementation has empty ivar list, just return.
+ if (numIvars == 0)
+ return;
assert(ivars && "missing @implementation ivars");
Sema::DeclTy *Sema::ActOnMethodDeclaration(
SourceLocation MethodLoc, SourceLocation EndLoc,
- tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel,
+ tok::TokenKind MethodType, ObjcDeclSpec &ReturnQT, TypeTy *ReturnType,
+ Selector Sel,
// optional arguments. The number of types/arguments is obtained
// from the Sel.getNumArgs().
- TypeTy **ArgTypes, IdentifierInfo **ArgNames,
+ ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind) {
llvm::SmallVector<ParmVarDecl*, 16> Params;
namespace clang {
// Semantic.
class DeclSpec;
+ class ObjcDeclSpec;
class Declarator;
class AttributeList;
// Parse.
SourceLocation BeginLoc, // location of the + or -.
SourceLocation EndLoc, // location of the ; or {.
tok::TokenKind MethodType, // tok::minus for instance, tok::plus for class.
+ ObjcDeclSpec &ReturnQT, // for return type's in inout etc.
TypeTy *ReturnType, // the method return type.
Selector Sel, // a unique name for the method.
+ ObjcDeclSpec *ArgQT, // for arguments' in inout etc.
TypeTy **ArgTypes, // non-zero when Sel.getNumArgs() > 0
IdentifierInfo **ArgNames, // non-zero when Sel.getNumArgs() > 0
AttributeList *AttrList, // optional
IdentifierInfo *ObjcPropertyAttrs[objc_NumAttrs];
bool isObjCPropertyAttribute();
- TypeTy *ParseObjCTypeName();
+ TypeTy *ParseObjCTypeName(ObjcDeclSpec &DS);
void ParseObjCMethodRequirement();
DeclTy *ParseObjCMethodPrototype(DeclTy *classOrCat,
tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);