Convert more counts to be zero based instead of -1 based, make them unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48429 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 7bdec93..2b88c0c 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -2178,7 +2178,7 @@
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();
@@ -2186,7 +2186,8 @@
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;
@@ -2634,9 +2635,9 @@
}
// 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) {
@@ -2672,7 +2673,7 @@
Result += "\n";
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
- if (IDecl->getImplDeclNumIvars() > 0) {
+ if (!IDecl->ivar_empty()) {
IVI = IDecl->ivar_begin();
IVE = IDecl->ivar_end();
} else {