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

Steve Naroff snaroff at apple.com
Tue Oct 2 13:26:23 PDT 2007


Author: snaroff
Date: Tue Oct  2 15:26:23 2007
New Revision: 42545

URL: http://llvm.org/viewvc/llvm-project?rev=42545&view=rev
Log:

Rename ObjcInterfaceDecl::getIsForwardDecl() to isForwardDecl().
Rename ObjcProtocolDecl::getIsForwardProtoDecl() to isForwardDecl().
Rename ObjcInterfaceDecl::setIsForwardDecl() to setForwardDecl().
Rename ObjcProtocolDecl::setIsForwardProtoDecl() to setForwardDecl().

Two reasons:

#1: boolean predicates should start with "is".
#2: Since these two sets of methods represent the same concept, they should be named the same (polymorphism is good:-)


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=42545&r1=42544&r2=42545&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Oct  2 15:26:23 2007
@@ -915,10 +915,10 @@
   ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(ClassName);
   if (IDecl) {
     // Class already seen. Is it a forward declaration?
-    if (!IDecl->getIsForwardDecl())
+    if (!IDecl->isForwardDecl())
       Diag(AtInterfaceLoc, diag::err_duplicate_class_def, ClassName->getName());
     else {
-      IDecl->setIsForwardDecl(false);
+      IDecl->setForwardDecl(false);
       IDecl->AllocIntfRefProtocols(NumProtocols);
     }
   }
@@ -945,7 +945,7 @@
       // Check that super class is previously defined
       SuperClassEntry = getObjCInterfaceDecl(SuperName); 
                               
-      if (!SuperClassEntry || SuperClassEntry->getIsForwardDecl()) {
+      if (!SuperClassEntry || SuperClassEntry->isForwardDecl()) {
         Diag(AtInterfaceLoc, diag::err_undef_superclass, SuperName->getName(),
              ClassName->getName()); 
       }
@@ -957,7 +957,7 @@
   for (unsigned int i = 0; i != NumProtocols; i++) {
     ObjcProtocolDecl* RefPDecl = getObjCProtocolDecl(S, ProtocolNames[i], 
 						     ClassLoc);
-    if (!RefPDecl || RefPDecl->getIsForwardProtoDecl())
+    if (!RefPDecl || RefPDecl->isForwardDecl())
       Diag(ClassLoc, diag::err_undef_protocolref,
            ProtocolNames[i]->getName(),
            ClassName->getName());
@@ -975,18 +975,18 @@
   ObjcProtocolDecl *PDecl = getObjCProtocolDecl(S, ProtocolName, ProtocolLoc);
   if (PDecl) {
     // Protocol already seen. Better be a forward protocol declaration
-    if (!PDecl->getIsForwardProtoDecl())
+    if (!PDecl->isForwardDecl())
       Diag(ProtocolLoc, diag::err_duplicate_protocol_def, 
            ProtocolName->getName());
     else {
-      PDecl->setIsForwardProtoDecl(false);
+      PDecl->setForwardDecl(false);
       PDecl->AllocReferencedProtocols(NumProtoRefs);
     }
   }
   else {
     PDecl = new ObjcProtocolDecl(AtProtoInterfaceLoc, NumProtoRefs, 
                                  ProtocolName);
-    PDecl->setIsForwardProtoDecl(false);
+    PDecl->setForwardDecl(false);
     // Chain & install the protocol decl into the identifier.
     PDecl->setNext(ProtocolName->getFETokenInfo<ScopedDecl>());
     ProtocolName->setFETokenInfo(PDecl);
@@ -996,7 +996,7 @@
   for (unsigned int i = 0; i != NumProtoRefs; i++) {
     ObjcProtocolDecl* RefPDecl = getObjCProtocolDecl(S, ProtoRefNames[i], 
 						     ProtocolLoc);
-    if (!RefPDecl || RefPDecl->getIsForwardProtoDecl())
+    if (!RefPDecl || RefPDecl->isForwardDecl())
       Diag(ProtocolLoc, diag::err_undef_protocolref,
 	   ProtoRefNames[i]->getName(),
            ProtocolName->getName());
@@ -1042,7 +1042,7 @@
   CDecl->setClassInterface(IDecl);
 
   /// Check that class of this category is already completely declared.
-  if (!IDecl || IDecl->getIsForwardDecl())
+  if (!IDecl || IDecl->isForwardDecl())
     Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
   else {
     /// Check for duplicate interface declaration for this category
@@ -1065,7 +1065,7 @@
   for (unsigned int i = 0; i != NumProtoRefs; i++) {
     ObjcProtocolDecl* RefPDecl = getObjCProtocolDecl(S, ProtoRefNames[i], 
 						     CategoryLoc);
-    if (!RefPDecl || RefPDecl->getIsForwardProtoDecl())
+    if (!RefPDecl || RefPDecl->isForwardDecl())
       Diag(CategoryLoc, diag::err_undef_protocolref,
 	   ProtoRefNames[i]->getName(),
            CategoryName->getName());
@@ -1087,7 +1087,7 @@
                                                          ClassName, IDecl,
                                                          CatName);
   /// Check that class of this category is already completely declared.
-  if (!IDecl || IDecl->getIsForwardDecl())
+  if (!IDecl || IDecl->isForwardDecl())
     Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
   /// TODO: Check that CatName, category name, is not used in another
   // implementation.

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Oct  2 15:26:23 2007
@@ -71,17 +71,14 @@
   /// List of categories defined for this class.
   ObjcCategoryDecl *ListCategories;
   
-  bool isForwardDecl; // declared with @class.
+  bool ForwardDecl; // declared with @class.
 public:
   ObjcInterfaceDecl(SourceLocation L, unsigned numRefProtos,
                     IdentifierInfo *Id, bool FD = false)
-    : TypeDecl(ObjcInterface, L, Id, 0),
-      SuperClass(0),
-      IntfRefProtocols(0), NumIntfRefProtocols(-1),
-      Ivars(0), NumIvars(-1),
+    : TypeDecl(ObjcInterface, L, Id, 0), SuperClass(0),
+      IntfRefProtocols(0), NumIntfRefProtocols(-1), Ivars(0), NumIvars(-1),
       InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1),
-      ListCategories(0),
-      isForwardDecl(FD) {
+      ListCategories(0), ForwardDecl(FD) {
         AllocIntfRefProtocols(numRefProtos);
       }
     
@@ -112,8 +109,8 @@
   void ObjcAddMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
                       ObjcMethodDecl **clsMethods, unsigned numClsMembers);
   
-  bool getIsForwardDecl() const { return isForwardDecl; }
-  void setIsForwardDecl(bool val) { isForwardDecl = val; }
+  bool isForwardDecl() const { return ForwardDecl; }
+  void setForwardDecl(bool val) { ForwardDecl = val; }
   
   void setIntfRefProtocols(int idx, ObjcProtocolDecl *OID) {
     assert((idx < NumIntfRefProtocols) && "index out of range");
@@ -324,8 +321,8 @@
   ObjcMethodDecl** getClsMethods() const { return ProtoClsMethods; }
   int getNumClsMethods() const { return NumProtoClsMethods; }
   
-  bool getIsForwardProtoDecl() const { return isForwardProtoDecl; }
-  void setIsForwardProtoDecl(bool val) { isForwardProtoDecl = val; }
+  bool isForwardDecl() const { return isForwardProtoDecl; }
+  void setForwardDecl(bool val) { isForwardProtoDecl = val; }
 
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcProtocol;





More information about the cfe-commits mailing list