[cfe-commits] r42705 - in /cfe/trunk: Sema/SemaDecl.cpp include/clang/AST/DeclObjC.h include/clang/AST/Type.h

Chris Lattner sabre at nondot.org
Sat Oct 6 13:06:00 PDT 2007


Author: lattner
Date: Sat Oct  6 15:05:59 2007
New Revision: 42705

URL: http://llvm.org/viewvc/llvm-project?rev=42705&view=rev
Log:
simplify the interface for creating ObjcForwardProtocolDecl


Modified:
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/include/clang/AST/Type.h

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42705&r1=42704&r2=42705&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sat Oct  6 15:05:59 2007
@@ -1036,13 +1036,12 @@
 Action::DeclTy *
 Sema::ActOnForwardProtocolDeclaration(Scope *S, SourceLocation AtProtocolLoc,
         IdentifierInfo **IdentList, unsigned NumElts) {
-  ObjcForwardProtocolDecl *FDecl = new ObjcForwardProtocolDecl(AtProtocolLoc, 
-                                                               NumElts);
+  llvm::SmallVector<ObjcProtocolDecl*, 32> Protocols;
   
   for (unsigned i = 0; i != NumElts; ++i) {
-    ObjcProtocolDecl *PDecl;
-    PDecl = getObjCProtocolDecl(S, IdentList[i], AtProtocolLoc);
-    if (!PDecl)  {// Already seen?
+    ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, IdentList[i],
+                                                  AtProtocolLoc);
+    if (!PDecl)  { // Already seen?
       PDecl = new ObjcProtocolDecl(SourceLocation(), 0, IdentList[i], true);
       // Chain & install the protocol decl into the identifier.
       PDecl->setNext(IdentList[i]->getFETokenInfo<ScopedDecl>());
@@ -1051,9 +1050,10 @@
     // Remember that this needs to be removed when the scope is popped.
     S->AddDecl(IdentList[i]);
     
-    FDecl->setForwardProtocolDecl((int)i, PDecl);
+    Protocols.push_back(PDecl);
   }
-  return FDecl;
+  return new ObjcForwardProtocolDecl(AtProtocolLoc,
+                                     &Protocols[0], Protocols.size());
 }
 
 Sema::DeclTy *Sema::ActOnStartCategoryInterface(Scope* S,

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=42705&r1=42704&r2=42705&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Oct  6 15:05:59 2007
@@ -381,12 +381,13 @@
   ObjcProtocolDecl **ReferencedProtocols;
   unsigned NumReferencedProtocols;
 public:
-  ObjcForwardProtocolDecl(SourceLocation L, unsigned nElts)
+  ObjcForwardProtocolDecl(SourceLocation L, 
+                          ObjcProtocolDecl **Elts, unsigned nElts)
   : TypeDecl(ObjcForwardProtocol, L, 0, 0) { 
+    NumReferencedProtocols = nElts;
     if (nElts) {
       ReferencedProtocols = new ObjcProtocolDecl*[nElts];
-      memset(ReferencedProtocols, '\0', nElts*sizeof(ObjcProtocolDecl*));
-      NumReferencedProtocols = nElts;
+      memcpy(ReferencedProtocols, Elts, nElts*sizeof(ObjcProtocolDecl*));
     } else {
       ReferencedProtocols = 0;
     }
@@ -407,7 +408,6 @@
     return ReferencedProtocols[idx];
   }
   
-  
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcForwardProtocol;
   }

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=42705&r1=42704&r2=42705&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Oct  6 15:05:59 2007
@@ -326,7 +326,6 @@
   friend class QualType;
 public:
   virtual void getAsStringInternal(std::string &InnerString) const = 0;
-  
   static bool classof(const Type *) { return true; }
 };
 





More information about the cfe-commits mailing list