[cfe-commits] r65129 - in /cfe/trunk: Driver/ASTConsumers.cpp Driver/RewriteObjC.cpp include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 20 10:04:31 PST 2009
Author: lattner
Date: Fri Feb 20 12:04:31 2009
New Revision: 65129
URL: http://llvm.org/viewvc/llvm-project?rev=65129&view=rev
Log:
move the interace list of @class to use ObjCList.
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=65129&r1=65128&r2=65129&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Fri Feb 20 12:04:31 2009
@@ -117,11 +117,10 @@
PrintObjCCompatibleAliasDecl(OID);
} else if (ObjCClassDecl *OFCD = dyn_cast<ObjCClassDecl>(D)) {
Out << "@class ";
- ObjCInterfaceDecl **ForwardDecls = OFCD->getForwardDecls();
- for (unsigned i = 0, e = OFCD->getNumForwardDecls(); i != e; ++i) {
- const ObjCInterfaceDecl *D = ForwardDecls[i];
- if (i) Out << ", ";
- Out << D->getNameAsString();
+ for (ObjCClassDecl::iterator I = OFCD->begin(), E = OFCD->end();
+ I != E; ++I) {
+ if (I != OFCD->begin()) Out << ", ";
+ Out << (*I)->getNameAsString();
}
Out << ";\n";
} else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=65129&r1=65128&r2=65129&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Fri Feb 20 12:04:31 2009
@@ -735,9 +735,6 @@
}
void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
- int numDecls = ClassDecl->getNumForwardDecls();
- ObjCInterfaceDecl **ForwardDecls = ClassDecl->getForwardDecls();
-
// Get the start location and compute the semi location.
SourceLocation startLoc = ClassDecl->getLocation();
const char *startBuf = SM->getCharacterData(startLoc);
@@ -750,8 +747,9 @@
typedefString += "// ";
typedefString.append(startBuf, semiPtr-startBuf+1);
typedefString += "\n";
- for (int i = 0; i < numDecls; i++) {
- ObjCInterfaceDecl *ForwardDecl = ForwardDecls[i];
+ for (ObjCClassDecl::iterator I = ClassDecl->begin(), E = ClassDecl->end();
+ I != E; ++I) {
+ ObjCInterfaceDecl *ForwardDecl = *I;
typedefString += "#ifndef _REWRITER_typedef_";
typedefString += ForwardDecl->getNameAsString();
typedefString += "\n";
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=65129&r1=65128&r2=65129&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Feb 20 12:04:31 2009
@@ -628,34 +628,26 @@
///
/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
///
-/// FIXME: This could be a transparent DeclContext (!)
class ObjCClassDecl : public Decl {
- ObjCInterfaceDecl **ForwardDecls;
- unsigned NumForwardDecls;
+ ObjCList<ObjCInterfaceDecl> ForwardDecls;
ObjCClassDecl(DeclContext *DC, SourceLocation L,
- ObjCInterfaceDecl **Elts, unsigned nElts);
- virtual ~ObjCClassDecl() {
- assert(ForwardDecls == 0 && "Destroy not called?");
+ ObjCInterfaceDecl *const *Elts, unsigned nElts)
+ : Decl(ObjCClass, DC, L) {
+ ForwardDecls.set(Elts, nElts);
}
+ virtual ~ObjCClassDecl() {}
public:
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
- ObjCInterfaceDecl **Elts, unsigned nElts);
+ ObjCInterfaceDecl *const *Elts, unsigned nElts);
- void setInterfaceDecl(unsigned idx, ObjCInterfaceDecl *OID) {
- assert(idx < NumForwardDecls && "index out of range");
- ForwardDecls[idx] = OID;
- }
- ObjCInterfaceDecl** getForwardDecls() const { return ForwardDecls; }
- int getNumForwardDecls() const { return NumForwardDecls; }
-
- typedef ObjCInterfaceDecl * const * iterator;
- iterator begin() const { return ForwardDecls; }
- iterator end() const { return ForwardDecls+NumForwardDecls; }
+ typedef ObjCList<ObjCInterfaceDecl>::iterator iterator;
+ iterator begin() const { return ForwardDecls.begin(); }
+ iterator end() const { return ForwardDecls.end(); }
static bool classof(const Decl *D) { return D->getKind() == ObjCClass; }
static bool classof(const ObjCClassDecl *D) { return true; }
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=65129&r1=65128&r2=65129&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Feb 20 12:04:31 2009
@@ -115,22 +115,11 @@
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
- ObjCInterfaceDecl **Elts, unsigned nElts) {
+ ObjCInterfaceDecl *const *Elts,
+ unsigned nElts) {
return new (C) ObjCClassDecl(DC, L, Elts, nElts);
}
-ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L,
- ObjCInterfaceDecl **Elts, unsigned nElts)
- : Decl(ObjCClass, DC, L) {
- if (nElts) {
- ForwardDecls = new ObjCInterfaceDecl*[nElts];
- memcpy(ForwardDecls, Elts, nElts*sizeof(ObjCInterfaceDecl*));
- } else {
- ForwardDecls = 0;
- }
- NumForwardDecls = nElts;
-}
-
void ObjCClassDecl::Destroy(ASTContext &C) {
// FIXME: There is no clear ownership policy now for referenced
@@ -141,9 +130,7 @@
// obviating this problem. Because of this situation, referenced
// ObjCInterfaceDecls are destroyed in ~TranslationUnit.
- delete [] ForwardDecls;
- ForwardDecls = 0;
-
+ ForwardDecls.clear();
Decl::Destroy(C);
}
More information about the cfe-commits
mailing list