Author: lattner
Date: Fri Jul 25 22:47:43 2008
New Revision: 54091

URL: http://llvm.org/viewvc/llvm-project?rev=54091&view=rev
Log:
simplify some code.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/category-1.m
    cfe/trunk/test/SemaObjC/class-def-test-1.m
    cfe/trunk/test/SemaObjC/class-proto-1.m
    cfe/trunk/test/SemaObjC/protocol-test-2.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Jul 25 22:47:43 2008
@@ -425,7 +425,7 @@
 DIAG(err_duplicate_class_def, ERROR,
      "duplicate interface declaration for class '%0'")
 DIAG(warn_undef_protocolref, WARNING,
-     "cannot find protocol definition for '%0', referenced by '%1'")
+     "cannot find protocol definition for '%0'")
 DIAG(err_duplicate_protocol_def, ERROR,
      "duplicate protocol declaration of '%0'")
 DIAG(err_undef_interface, ERROR,

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Jul 25 22:47:43 2008
@@ -777,9 +777,10 @@
   /// issues error if they are not declared. It returns list of valid
   /// protocols found.
   virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
+                                       bool WarnOnDeclarations,
                                        const IdentifierLocPair *ProtocolId,
                                        unsigned NumProtocols,
-                                    llvm::SmallVectorImpl<DeclTy*> &Protocols) 
{
+                                 llvm::SmallVectorImpl<DeclTy*> &ResProtos) {
   }
 
   //===----------------------- Obj-C Expressions 
--------------------------===//

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jul 25 22:47:43 2008
@@ -435,7 +435,7 @@
       ParseObjCProtocolReferences(ProtocolRefs, EndProtoLoc);
       
       llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
-      Actions.FindProtocolDeclaration(Loc, 
+      Actions.FindProtocolDeclaration(Loc, false,
                                       &ProtocolRefs[0], ProtocolRefs.size(),
                                       ProtocolDecl);
       DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
@@ -575,7 +575,7 @@
         llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs;
         ParseObjCProtocolReferences(ProtocolRefs, EndProtoLoc);
         llvm::SmallVector<DeclTy *, 8> ProtocolDecl;
-        Actions.FindProtocolDeclaration(Loc, 
+        Actions.FindProtocolDeclaration(Loc, false,
                                         &ProtocolRefs[0], ProtocolRefs.size(),
                                         ProtocolDecl);
         DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());

Modified: cfe/trunk/lib/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Jul 25 22:47:43 2008
@@ -655,6 +655,7 @@
                                                   unsigned NumElts);
   
   virtual void FindProtocolDeclaration(SourceLocation TypeLoc,
+                                       bool WarnOnDeclarations,
                                        const IdentifierLocPair *ProtocolId,
                                        unsigned NumProtocols,
                                    llvm::SmallVectorImpl<DeclTy *> &Protocols);

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 25 22:47:43 2008
@@ -144,7 +144,7 @@
       else {
         if (RefPDecl->isForwardDecl())
           Diag(ProtocolNames[i].second, diag::warn_undef_protocolref,
-               ProtocolNames[i].first->getName(), ClassName->getName());
+               ProtocolNames[i].first->getName());
         RefProtos.push_back(RefPDecl);
       }
     }
@@ -230,7 +230,7 @@
       else {
         if (RefPDecl->isForwardDecl())
           Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref,
-               ProtoRefNames[i].first->getName(), ProtocolName->getName());
+               ProtoRefNames[i].first->getName());
         Protocols.push_back(RefPDecl);
       }
     }
@@ -245,16 +245,24 @@
 /// issuer error if they are not declared. It returns list of protocol
 /// declarations in its 'Protocols' argument.
 void
-Sema::FindProtocolDeclaration(SourceLocation TypeLoc,
+Sema::FindProtocolDeclaration(SourceLocation TypeLoc, bool WarnOnDeclarations,
                               const IdentifierLocPair *ProtocolId,
                               unsigned NumProtocols,
                               llvm::SmallVectorImpl<DeclTy*> &Protocols) {
   for (unsigned i = 0; i != NumProtocols; ++i) {
-    if (ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first])
-      Protocols.push_back(PDecl); 
-    else
+    ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolId[i].first];
+    if (!PDecl) {
       Diag(ProtocolId[i].second, diag::err_undeclared_protocol, 
            ProtocolId[i].first->getName());
+      continue;
+    }
+
+    // If this is a forward declaration and we are supposed to warn in this
+    // case, do it.
+    if (WarnOnDeclarations && PDecl->isForwardDecl())
+      Diag(ProtocolId[i].second, diag::warn_undef_protocolref,
+           ProtocolId[i].first->getName());
+    Protocols.push_back(PDecl); 
   }
 }
 
@@ -444,7 +452,7 @@
       else {
         if (RefPDecl->isForwardDecl())
           Diag(ProtoRefNames[i].second, diag::warn_undef_protocolref,
-               ProtoRefNames[i].first->getName(), CategoryName->getName());
+               ProtoRefNames[i].first->getName());
         RefProtocols.push_back(RefPDecl);
       }
     }

Modified: cfe/trunk/test/SemaObjC/category-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/category-1.m?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/category-1.m (original)
+++ cfe/trunk/test/SemaObjC/category-1.m Fri Jul 25 22:47:43 2008
@@ -4,7 +4,7 @@
 
 @protocol p1,p2,p3;
 
[EMAIL PROTECTED] MyClass1 (Category1)  <p1> // expected-warning {{cannot find 
protocol definition for 'p1', referenced by 'Category1'}}
[EMAIL PROTECTED] MyClass1 (Category1)  <p1> // expected-warning {{cannot find 
protocol definition for 'p1'}}
 @end
 
 @interface MyClass1 (Category1)  // expected-warning {{duplicate interface 
declaration for category 'MyClass1(Category1)'}}
@@ -27,7 +27,7 @@
 
 @protocol p3 @end
 
[EMAIL PROTECTED] MyClass1 (Category) <p2, p3> @end  // expected-warning 
{{cannot find protocol definition for 'p2', referenced by 'Category'}}
[EMAIL PROTECTED] MyClass1 (Category) <p2, p3> @end  // expected-warning 
{{cannot find protocol definition for 'p2'}}
 
 @interface MyClass  (Category) @end // expected-error {{cannot find interface 
declaration for 'MyClass'}}
 

Modified: cfe/trunk/test/SemaObjC/class-def-test-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-def-test-1.m?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/class-def-test-1.m (original)
+++ cfe/trunk/test/SemaObjC/class-def-test-1.m Fri Jul 25 22:47:43 2008
@@ -2,7 +2,7 @@
 
 @protocol SUPER;
 
[EMAIL PROTECTED] SUPER <SUPER> @end // expected-warning {{cannot find protocol 
definition for 'SUPER', referenced by 'SUPER'}}
[EMAIL PROTECTED] SUPER <SUPER> @end // expected-warning {{cannot find protocol 
definition for 'SUPER'}}
 
 typedef int INTF; //  expected-error {{previous definition is here}}
 

Modified: cfe/trunk/test/SemaObjC/class-proto-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-proto-1.m?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/class-proto-1.m (original)
+++ cfe/trunk/test/SemaObjC/class-proto-1.m Fri Jul 25 22:47:43 2008
@@ -14,14 +14,14 @@
 
 @interface I1 <p1> @end
 
[EMAIL PROTECTED] E1 <p2> @end  // expected-warning {{cannot find protocol 
definition for 'p2', referenced by 'E1'}}
[EMAIL PROTECTED] E1 <p2> @end  // expected-warning {{cannot find protocol 
definition for 'p2'}}
 
 @protocol p2 @end
 
 
 @interface I2 <p1,p2> @end
 
[EMAIL PROTECTED] E2 <p1,p2,p3> @end  // expected-warning {{cannot find 
protocol definition for 'p3', referenced by 'E2'}}
[EMAIL PROTECTED] E2 <p1,p2,p3> @end  // expected-warning {{cannot find 
protocol definition for 'p3'}}
 
 @class U1, U2;
 

Modified: cfe/trunk/test/SemaObjC/protocol-test-2.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-test-2.m?rev=54091&r1=54090&r2=54091&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-test-2.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-test-2.m Fri Jul 25 22:47:43 2008
@@ -10,7 +10,7 @@
 - (INTF1<p1>*) meth;
 @end
 
[EMAIL PROTECTED] PROTO2<p1> // expected-warning {{cannot find protocol 
definition for 'p1', referenced by 'PROTO2'}}
[EMAIL PROTECTED] PROTO2<p1> // expected-warning {{cannot find protocol 
definition for 'p1'}}
 @end
 
 @protocol p1 @end
@@ -27,5 +27,5 @@
 @protocol p2 <p1>
 @end
 
[EMAIL PROTECTED] PROTO4 <p1, p2, PROTO, PROTO3, p3> // expected-warning 
{{cannot find protocol definition for 'p3', referenced by 'PROTO4'}}
[EMAIL PROTECTED] PROTO4 <p1, p2, PROTO, PROTO3, p3> // expected-warning 
{{cannot find protocol definition for 'p3'}}
 @end


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to