From: Chris Lattner Date: Sat, 6 Oct 2007 18:52:10 +0000 (+0000) Subject: stub out some printing of objc decls. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fa5e65d08aee1875c5f2a841c8b0b4069bd00e5;p=clang stub out some printing of objc decls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42703 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/ASTStreamers.cpp b/Driver/ASTStreamers.cpp index 61490d3401..7f3b715570 100644 --- a/Driver/ASTStreamers.cpp +++ b/Driver/ASTStreamers.cpp @@ -92,10 +92,27 @@ namespace { } } else if (TypedefDecl *TD = dyn_cast(D)) { PrintTypeDefDecl(TD); - } else if (ObjcInterfaceDecl *OID = dyn_cast(D)) { - PrintObjcInterfaceDecl(OID); } else if (ScopedDecl *SD = dyn_cast(D)) { fprintf(stderr, "Read top-level variable decl: '%s'\n", SD->getName()); + } else if (ObjcInterfaceDecl *OID = dyn_cast(D)) { + PrintObjcInterfaceDecl(OID); + } else if (ObjcForwardProtocolDecl *OFPD = + dyn_cast(D)) { + fprintf(stderr, "@protocol "); + for (unsigned i = 0, e = OFPD->getNumForwardDecls(); i != e; ++i) { + const ObjcProtocolDecl *D = OFPD->getForwardProtocolDecl(i); + if (i) fprintf(stderr, ", "); + fprintf(stderr, "%s", D->getName()); + } + fprintf(stderr, "\n"); + } else if (ObjcImplementationDecl *OID = + dyn_cast(D)) { + fprintf(stderr, "@implementation %s [printing todo]\n", + OID->getName()); + } else if (isa(D)) { + fprintf(stderr, "@class [printing todo]\n"); + } else { + assert(0 && "Unknown decl type!"); } } }; @@ -124,6 +141,12 @@ namespace { PrintTypeDefDecl(TD); } else if (ScopedDecl *SD = dyn_cast(D)) { fprintf(stderr, "Read top-level variable decl: '%s'\n", SD->getName()); + } else if (ObjcInterfaceDecl *OID = dyn_cast(D)) { + fprintf(stderr, "Read objc interface '%s'\n", OID->getName()); + } else if (isa(D)) { + fprintf(stderr, "Read objc fwd protocol decl\n"); + } else { + assert(0 && "Unknown decl type!"); } } }; diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index ec132cc7e4..0d1bc7fb6d 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -378,8 +378,8 @@ public: /// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo; /// class ObjcForwardProtocolDecl : public TypeDecl { - ObjcProtocolDecl **ReferencedProtocols; // Null if not defined. - int NumReferencedProtocols; // -1 if not defined. + ObjcProtocolDecl **ReferencedProtocols; + unsigned NumReferencedProtocols; public: ObjcForwardProtocolDecl(SourceLocation L, unsigned nElts) : TypeDecl(ObjcForwardProtocol, L, 0, 0) { @@ -387,12 +387,27 @@ public: ReferencedProtocols = new ObjcProtocolDecl*[nElts]; memset(ReferencedProtocols, '\0', nElts*sizeof(ObjcProtocolDecl*)); NumReferencedProtocols = nElts; + } else { + ReferencedProtocols = 0; } } - void setForwardProtocolDecl(int idx, ObjcProtocolDecl *OID) { - assert((idx < NumReferencedProtocols) && "index out of range"); + void setForwardProtocolDecl(unsigned idx, ObjcProtocolDecl *OID) { + assert(idx < NumReferencedProtocols && "index out of range"); ReferencedProtocols[idx] = OID; } + + unsigned getNumForwardDecls() const { return NumReferencedProtocols; } + + ObjcProtocolDecl *getForwardProtocolDecl(unsigned idx) { + assert(idx < NumReferencedProtocols && "index out of range"); + return ReferencedProtocols[idx]; + } + const ObjcProtocolDecl *getForwardProtocolDecl(unsigned idx) const { + assert(idx < NumReferencedProtocols && "index out of range"); + return ReferencedProtocols[idx]; + } + + static bool classof(const Decl *D) { return D->getKind() == ObjcForwardProtocol; } @@ -581,7 +596,7 @@ class ObjcImplementationDecl : public TypeDecl { ObjcMethodDecl **ClassMethods; // Null if not defined int NumClassMethods; // -1 if not defined - public: +public: ObjcImplementationDecl(SourceLocation L, IdentifierInfo *Id, ObjcInterfaceDecl* superDecl) : TypeDecl(ObjcImplementation, L, Id, 0),