[cfe-commits] r44930 - in /cfe/trunk: AST/Decl.cpp Driver/ASTConsumers.cpp Driver/RewriteTest.cpp include/clang/AST/DeclObjC.h
Chris Lattner
sabre at nondot.org
Tue Dec 11 23:56:43 PST 2007
Author: lattner
Date: Wed Dec 12 01:56:42 2007
New Revision: 44930
URL: http://llvm.org/viewvc/llvm-project?rev=44930&view=rev
Log:
more cleanups changing things like getInstanceVariables to iterators.
Modified:
cfe/trunk/AST/Decl.cpp
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/include/clang/AST/DeclObjC.h
Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=44930&r1=44929&r2=44930&view=diff
==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Wed Dec 12 01:56:42 2007
@@ -393,12 +393,11 @@
IdentifierInfo *ID, ObjcInterfaceDecl *&clsDeclared) {
ObjcInterfaceDecl* ClassDecl = this;
while (ClassDecl != NULL) {
- ObjcIvarDecl **ivars = ClassDecl->getInstanceVariables();
- int ivarCount = ClassDecl->getNumInstanceVariables();
- for (int i = 0; i < ivarCount; ++i) {
- if (ivars[i]->getIdentifier() == ID) {
+ for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end();
+ I != E; ++I) {
+ if ((*I)->getIdentifier() == ID) {
clsDeclared = ClassDecl;
- return ivars[i];
+ return *I;
}
}
ClassDecl = ClassDecl->getSuperClass();
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=44930&r1=44929&r2=44930&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Wed Dec 12 01:56:42 2007
@@ -172,14 +172,12 @@
else
Out << '\n';
- int NumIvars = OID->getNumInstanceVariables();
- if (NumIvars > 0) {
- ObjcIvarDecl **Ivars = OID->getInstanceVariables();
+ if (OID->getNumInstanceVariables() > 0) {
Out << '{';
- for (int i = 0; i < NumIvars; i++) {
- Out << '\t' << Ivars[i]->getType().getAsString()
- << ' ' << Ivars[i]->getName()
- << ";\n";
+ for (ObjcInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
+ E = OID->ivar_end(); I != E; ++I) {
+ Out << '\t' << (*I)->getType().getAsString()
+ << ' ' << (*I)->getName() << ";\n";
}
Out << "}\n";
}
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44930&r1=44929&r2=44930&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Dec 12 01:56:42 2007
@@ -2090,10 +2090,6 @@
std::string &Result) {
ObjcInterfaceDecl *CDecl = IDecl->getClassInterface();
- // Build _objc_ivar_list metadata for classes ivars if needed
- int NumIvars = IDecl->getImplDeclNumIvars() > 0
- ? IDecl->getImplDeclNumIvars()
- : (CDecl ? CDecl->getNumInstanceVariables() : 0);
// Explictly declared @interface's are already synthesized.
if (CDecl->ImplicitInterfaceDecl()) {
// FIXME: Implementation of a class with no @interface (legacy) doese not
@@ -2101,6 +2097,10 @@
SynthesizeObjcInternalStruct(CDecl, Result);
}
+ // Build _objc_ivar_list metadata for classes ivars if needed
+ int NumIvars = IDecl->getImplDeclNumIvars() > 0
+ ? IDecl->getImplDeclNumIvars()
+ : (CDecl ? CDecl->getNumInstanceVariables() : 0);
if (NumIvars > 0) {
static bool objc_ivar = false;
if (!objc_ivar) {
@@ -2133,28 +2133,33 @@
"{\n\t";
Result += utostr(NumIvars);
Result += "\n";
-
- ObjcIvarDecl **Ivars = IDecl->getImplDeclIVars()
- ? IDecl->getImplDeclIVars()
- : CDecl->getInstanceVariables();
+
+ ObjcInterfaceDecl::ivar_iterator IVI, IVE;
+ if (IDecl->getImplDeclNumIvars() > 0) {
+ IVI = IDecl->ivar_begin();
+ IVE = IDecl->ivar_end();
+ } else {
+ IVI = CDecl->ivar_begin();
+ IVE = CDecl->ivar_end();
+ }
Result += "\t,{{\"";
- Result += Ivars[0]->getName();
+ Result += (*IVI)->getName();
Result += "\", \"";
std::string StrEncoding;
- Context->getObjcEncodingForType(Ivars[0]->getType(), StrEncoding);
+ Context->getObjcEncodingForType((*IVI)->getType(), StrEncoding);
Result += StrEncoding;
Result += "\", ";
- SynthesizeIvarOffsetComputation(IDecl, Ivars[0], Result);
+ SynthesizeIvarOffsetComputation(IDecl, *IVI, Result);
Result += "}\n";
- for (int i = 1; i < NumIvars; i++) {
+ for (++IVI; IVI != IVE; ++IVI) {
Result += "\t ,{\"";
- Result += Ivars[i]->getName();
+ Result += (*IVI)->getName();
Result += "\", \"";
std::string StrEncoding;
- Context->getObjcEncodingForType(Ivars[i]->getType(), StrEncoding);
+ Context->getObjcEncodingForType((*IVI)->getType(), StrEncoding);
Result += StrEncoding;
Result += "\", ";
- SynthesizeIvarOffsetComputation(IDecl, Ivars[i], Result);
+ SynthesizeIvarOffsetComputation(IDecl, (*IVI), Result);
Result += "}\n";
}
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44930&r1=44929&r2=44930&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 01:56:42 2007
@@ -111,9 +111,12 @@
}
int getNumIntfRefProtocols() const { return NumReferencedProtocols; }
- ObjcIvarDecl **getInstanceVariables() const { return Ivars; }
int getNumInstanceVariables() const { return NumIvars; }
+ typedef ObjcIvarDecl * const *ivar_iterator;
+ ivar_iterator ivar_begin() const { return Ivars; }
+ ivar_iterator ivar_end() const { return Ivars+(NumIvars == -1 ?0 : NumIvars);}
+
ObjcMethodDecl** getInstanceMethods() const { return InstanceMethods; }
int getNumInstanceMethods() const { return NumInstanceMethods; }
@@ -580,7 +583,6 @@
unsigned getNumInstanceMethods() const { return InstanceMethods.size(); }
unsigned getNumClassMethods() const { return ClassMethods.size(); }
- ObjcIvarDecl **getImplDeclIVars() const { return Ivars; }
unsigned getImplDeclNumIvars() const { return NumIvars; }
More information about the cfe-commits
mailing list