if (ObjCSynthesizedStructs.count(CDecl))
return;
ObjCInterfaceDecl *RCDecl = CDecl->getSuperClass();
- int NumIvars = CDecl->getNumInstanceVariables();
+ int NumIvars = CDecl->ivar_size();
SourceLocation LocStart = CDecl->getLocStart();
SourceLocation LocEnd = CDecl->getLocEnd();
const char *endBuf = SM->getCharacterData(LocEnd);
// If no ivars and no root or if its root, directly or indirectly,
// have no ivars (thus not synthesized) then no need to synthesize this class.
- if (NumIvars <= 0 && (!RCDecl || !ObjCSynthesizedStructs.count(RCDecl))) {
+ if ((CDecl->isForwardDecl() || NumIvars == 0) &&
+ (!RCDecl || !ObjCSynthesizedStructs.count(RCDecl))) {
endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
ReplaceText(LocStart, endBuf-startBuf, Result.c_str(), Result.size());
return;
}
// Build _objc_ivar_list metadata for classes ivars if needed
- int NumIvars = IDecl->getImplDeclNumIvars() > 0
- ? IDecl->getImplDeclNumIvars()
- : (CDecl ? CDecl->getNumInstanceVariables() : 0);
+ unsigned NumIvars = !IDecl->ivar_empty()
+ ? IDecl->ivar_size()
+ : (CDecl ? CDecl->ivar_size() : 0);
if (NumIvars > 0) {
static bool objc_ivar = false;
if (!objc_ivar) {
Result += "\n";
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
- if (IDecl->getImplDeclNumIvars() > 0) {
+ if (!IDecl->ivar_empty()) {
IVI = IDecl->ivar_begin();
IVE = IDecl->ivar_end();
} else {
/// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
ObjCIvarDecl **Ivars; // Null if not defined.
- int NumIvars; // -1 if not defined.
+ unsigned NumIvars; // 0 if none.
/// instance methods
ObjCMethodDecl **InstanceMethods; // Null if not defined
IdentifierInfo *Id, bool FD, bool isInternal)
: TypeDecl(ObjCInterface, atLoc, Id, 0), SuperClass(0),
ReferencedProtocols(0), NumReferencedProtocols(0), Ivars(0),
- NumIvars(-1),
+ NumIvars(0),
InstanceMethods(0), NumInstanceMethods(-1),
ClassMethods(0), NumClassMethods(0),
CategoryList(0), PropertyDecl(0), NumPropertyDecl(-1),
}
unsigned getNumIntfRefProtocols() const { return NumReferencedProtocols; }
- int getNumInstanceVariables() const { return NumIvars; }
-
typedef ObjCIvarDecl * const *ivar_iterator;
- unsigned ivar_size() const { return NumIvars == -1 ?0 : NumIvars; }
ivar_iterator ivar_begin() const { return Ivars; }
ivar_iterator ivar_end() const { return Ivars + ivar_size();}
+ unsigned ivar_size() const { return NumIvars; }
int getNumInstanceMethods() const { return NumInstanceMethods; }
unsigned getNumClassMethods() const { return NumClassMethods; }
/// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
ObjCIvarDecl **Ivars; // Null if not specified
- int NumIvars; // -1 if not defined.
+ unsigned NumIvars; // 0 if none.
/// implemented instance methods
llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
ObjCInterfaceDecl *superDecl)
: NamedDecl(ObjCImplementation, L, Id),
ClassInterface(classInterface), SuperClass(superDecl),
- Ivars(0), NumIvars(-1) {}
+ Ivars(0), NumIvars(0) {}
public:
static ObjCImplementationDecl *Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id,
ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
- void setSuperClass(ObjCInterfaceDecl * superCls)
- { SuperClass = superCls; }
+ void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
int getNumInstanceMethods() const { return InstanceMethods.size(); }
unsigned getNumClassMethods() const { return ClassMethods.size(); }
- int getImplDeclNumIvars() const { return NumIvars; }
-
-
typedef llvm::SmallVector<ObjCMethodDecl*, 32>::const_iterator
instmeth_iterator;
instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); }
typedef ObjCIvarDecl * const *ivar_iterator;
ivar_iterator ivar_begin() const { return Ivars; }
- ivar_iterator ivar_end() const {return Ivars+(NumIvars == -1 ? 0 : NumIvars);}
+ ivar_iterator ivar_end() const { return Ivars+NumIvars; }
+ unsigned ivar_size() const { return NumIvars; }
+ bool ivar_empty() const { return NumIvars == 0; }
static bool classof(const Decl *D) {
return D->getKind() == ObjCImplementation;