[llvm-branch-commits] [cfe-branch] r169451 - in /cfe/branches/release_32: ./ include/clang/Sema/Scope.h lib/Parse/ParseStmt.cpp lib/Sema/IdentifierResolver.cpp test/CXX/basic/basic.scope/basic.scope.local/p2.cpp

Pawel Wodnicki pawel at 32bitmicro.com
Wed Dec 5 15:48:42 PST 2012


Author: pawel
Date: Wed Dec  5 17:48:42 2012
New Revision: 169451

URL: http://llvm.org/viewvc/llvm-project?rev=169451&view=rev
Log:
Merging r167766: into the 3.2 release branch.

Fix more try scoping bugs introduced by r167650.

Introduces more clear scoping flags & flag combinations which should hopefully
be more understandable.

Modified:
    cfe/branches/release_32/   (props changed)
    cfe/branches/release_32/include/clang/Sema/Scope.h
    cfe/branches/release_32/lib/Parse/ParseStmt.cpp
    cfe/branches/release_32/lib/Sema/IdentifierResolver.cpp
    cfe/branches/release_32/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp

Propchange: cfe/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  5 17:48:42 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:167749,167762,167780,167788,167790,167813-167814,167868,167884,167918,167920,167925,167935,168024,168063,168124,168269,168277-168278,168297,168303,168355,168379,168674,168818
+/cfe/trunk:167749,167762,167766,167780,167788,167790,167813-167814,167868,167884,167918,167920,167925,167935,168024,168063,168124,168269,168277-168278,168297,168303,168355,168379,168674,168818,169084
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_32/include/clang/Sema/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/include/clang/Sema/Scope.h?rev=169451&r1=169450&r2=169451&view=diff
==============================================================================
--- cfe/branches/release_32/include/clang/Sema/Scope.h (original)
+++ cfe/branches/release_32/include/clang/Sema/Scope.h Wed Dec  5 17:48:42 2012
@@ -84,11 +84,18 @@
     /// TryScope - This is the scope of a C++ try statement.
     TryScope = 0x1000,
 
+    /// CatchScope - This is the scope of a C++ catch statement.
+    CatchScope = 0x2000,
+
+    /// FnTryCatchScope - This is the scope for a function-level C++ try or
+    /// catch scope.
+    FnTryCatchScope = 0x4000,
+
     /// FnTryScope - This is the scope of a function-level C++ try scope.
-    FnTryScope = 0x3000,
+    FnTryScope = TryScope | FnTryCatchScope,
 
     /// FnCatchScope - This is the scope of a function-level C++ catch scope.
-    FnCatchScope = 0x4000
+    FnCatchScope = CatchScope | FnTryCatchScope
   };
 private:
   /// The parent scope for this scope.  This is null for the translation-unit

Modified: cfe/branches/release_32/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/lib/Parse/ParseStmt.cpp?rev=169451&r1=169450&r2=169451&view=diff
==============================================================================
--- cfe/branches/release_32/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/release_32/lib/Parse/ParseStmt.cpp Wed Dec  5 17:48:42 2012
@@ -2197,7 +2197,7 @@
   // The name in a catch exception-declaration is local to the handler and
   // shall not be redeclared in the outermost block of the handler.
   ParseScope CatchScope(this, Scope::DeclScope | Scope::ControlScope |
-                          (FnCatch ? Scope::FnCatchScope : 0));
+                          (FnCatch ? Scope::FnCatchScope : Scope::CatchScope));
 
   // exception-declaration is equivalent to '...' or a parameter-declaration
   // without default arguments.

Modified: cfe/branches/release_32/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/lib/Sema/IdentifierResolver.cpp?rev=169451&r1=169450&r2=169451&view=diff
==============================================================================
--- cfe/branches/release_32/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/release_32/lib/Sema/IdentifierResolver.cpp Wed Dec  5 17:48:42 2012
@@ -135,16 +135,13 @@
       // of the controlled statement.
       //
       assert(S->getParent() && "No TUScope?");
-      if (S->getFlags() & Scope::FnTryScope)
-        return S->getParent()->isDeclScope(D);
       if (S->getParent()->getFlags() & Scope::ControlScope) {
-        if (S->getParent()->getFlags() & Scope::FnCatchScope) {
-          S = S->getParent();
-          if (S->isDeclScope(D))
-            return true;
-        }
-        return S->getParent()->isDeclScope(D);
+        S = S->getParent();
+        if (S->isDeclScope(D))
+          return true;
       }
+      if (S->getFlags() & Scope::FnTryCatchScope)
+        return S->getParent()->isDeclScope(D);
     }
     return false;
   }

Modified: cfe/branches/release_32/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp?rev=169451&r1=169450&r2=169451&view=diff
==============================================================================
--- cfe/branches/release_32/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp (original)
+++ cfe/branches/release_32/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp Wed Dec  5 17:48:42 2012
@@ -35,3 +35,26 @@
     int i; // expected-error{{redefinition of 'i'}}
   }
 }
+
+void func8() {
+  int i;
+  try {
+    int i;
+  } catch (...) {
+  }
+}
+
+void func9() {
+  if (bool b = true)
+    try {
+      int b; // FIXME: this probably should be invalid, maybe
+    } catch (...) {
+    }
+}
+
+void func10() {
+  if (bool b = true)
+    if (true) {
+      int b; // FIXME: decide whether this is valid
+    }
+}





More information about the llvm-branch-commits mailing list