[cfe-commits] r42706 - in /cfe/trunk: Sema/SemaDecl.cpp include/clang/AST/DeclObjC.h
Chris Lattner
sabre at nondot.org
Sat Oct 6 13:08:38 PDT 2007
Author: lattner
Date: Sat Oct 6 15:08:36 2007
New Revision: 42706
URL: http://llvm.org/viewvc/llvm-project?rev=42706&view=rev
Log:
simplify the interface to create ObjcClassDecl's.
Modified:
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/include/clang/AST/DeclObjC.h
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42706&r1=42705&r2=42706&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sat Oct 6 15:08:36 2007
@@ -1372,12 +1372,11 @@
Sema::ActOnForwardClassDeclaration(Scope *S, SourceLocation AtClassLoc,
IdentifierInfo **IdentList, unsigned NumElts)
{
- ObjcClassDecl *CDecl = new ObjcClassDecl(AtClassLoc, NumElts);
-
+ llvm::SmallVector<ObjcInterfaceDecl*, 32> Interfaces;
+
for (unsigned i = 0; i != NumElts; ++i) {
- ObjcInterfaceDecl *IDecl;
- IDecl = getObjCInterfaceDecl(IdentList[i]);
- if (!IDecl) {// Already seen?
+ ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(IdentList[i]);
+ if (!IDecl) { // Not already seen? Make a forward decl.
IDecl = new ObjcInterfaceDecl(SourceLocation(), 0, IdentList[i], true);
// Chain & install the interface decl into the identifier.
IDecl->setNext(IdentList[i]->getFETokenInfo<ScopedDecl>());
@@ -1385,10 +1384,11 @@
}
// Remember that this needs to be removed when the scope is popped.
S->AddDecl(IdentList[i]);
-
- CDecl->setInterfaceDecl((int)i, IDecl);
+
+ Interfaces.push_back(IDecl);
}
- return CDecl;
+
+ return new ObjcClassDecl(AtClassLoc, &Interfaces[0], Interfaces.size());
}
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=42706&r1=42705&r2=42706&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Oct 6 15:08:36 2007
@@ -351,19 +351,21 @@
/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
///
class ObjcClassDecl : public TypeDecl {
- ObjcInterfaceDecl **ForwardDecls; // Null if not defined.
- int NumForwardDecls; // -1 if not defined.
+ ObjcInterfaceDecl **ForwardDecls;
+ unsigned NumForwardDecls;
public:
- ObjcClassDecl(SourceLocation L, unsigned nElts)
+ ObjcClassDecl(SourceLocation L, ObjcInterfaceDecl **Elts, unsigned nElts)
: TypeDecl(ObjcClass, L, 0, 0) {
if (nElts) {
ForwardDecls = new ObjcInterfaceDecl*[nElts];
- memset(ForwardDecls, '\0', nElts*sizeof(ObjcInterfaceDecl*));
+ memcpy(ForwardDecls, Elts, nElts*sizeof(ObjcInterfaceDecl*));
+ } else {
+ ForwardDecls = 0;
}
NumForwardDecls = nElts;
}
- void setInterfaceDecl(int idx, ObjcInterfaceDecl *OID) {
- assert((idx < NumForwardDecls) && "index out of range");
+ void setInterfaceDecl(unsigned idx, ObjcInterfaceDecl *OID) {
+ assert(idx < NumForwardDecls && "index out of range");
ForwardDecls[idx] = OID;
}
static bool classof(const Decl *D) {
More information about the cfe-commits
mailing list