[cfe-commits] r69486 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaObjC/scope-check.m

Chris Lattner sabre at nondot.org
Sat Apr 18 15:35:34 PDT 2009


Author: lattner
Date: Sat Apr 18 17:35:34 2009
New Revision: 69486

URL: http://llvm.org/viewvc/llvm-project?rev=69486&view=rev
Log:
I didn't understand how @catches were chained.  Now that I get it, fix
the scope checker to not think @catches are nested in each other, eliminating
some bogus notes.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaObjC/scope-check.m

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Apr 18 17:35:34 2009
@@ -3022,15 +3022,8 @@
     // it.  This makes the second scan not have to walk the AST again.
     LabelAndGotoScopes[S] = ParentScope;
     Jumps.push_back(S);
-  } else if (ObjCAtCatchStmt *AC = dyn_cast<ObjCAtCatchStmt>(S)) {
-    // @catch always starts a new scope.
-    // FIXME: We have to do this because @catches are nested inside each other,
-    // which seems weird and causes us to emit wierd diagnostics.
-    Scopes.push_back(GotoScope(ParentScope, diag::note_protected_by_objc_catch,
-                               AC->getAtCatchLoc()));
-    ParentScope = Scopes.size()-1;
   }
-
+  
   for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); CI != E;
        ++CI) {
     Stmt *SubStmt = *CI;
@@ -3063,11 +3056,17 @@
       if (Stmt *TryPart = AT->getTryBody())
         BuildScopeInformation(TryPart, Scopes.size()-1);
 
-      // Jump from the catch or finally to the try is not valid.
-      if (ObjCAtCatchStmt *AC = AT->getCatchStmts())
+      // Jump from the catch to the finally or try is not valid.
+      for (ObjCAtCatchStmt *AC = AT->getCatchStmts(); AC;
+           AC = AC->getNextCatchStmt()) {
+        Scopes.push_back(GotoScope(ParentScope,
+                                   diag::note_protected_by_objc_catch,
+                                   AC->getAtCatchLoc()));
         // @catches are nested and it isn't 
-        BuildScopeInformation(AC, ParentScope);
+        BuildScopeInformation(AC->getCatchBody(), Scopes.size()-1);
+      }
       
+      // Jump from the finally to the try or catch is not valid.
       if (ObjCAtFinallyStmt *AF = AT->getFinallyStmt()) {
         Scopes.push_back(GotoScope(ParentScope,
                                    diag::note_protected_by_objc_finally,

Modified: cfe/trunk/test/SemaObjC/scope-check.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/scope-check.m?rev=69486&r1=69485&r2=69486&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/scope-check.m (original)
+++ cfe/trunk/test/SemaObjC/scope-check.m Sat Apr 18 17:35:34 2009
@@ -39,8 +39,8 @@
   
   goto L8;  // expected-error{{illegal goto into protected scope}}
   @try { 
-  } @catch (A *c) { // expected-note {{jump bypasses initialization of @catch block}}
-  } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
+  } @catch (A *c) {
+  } @catch (B *c) {
   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L8: ;
   }





More information about the cfe-commits mailing list