[cfe-commits] r115266 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/auto-obj-dtors-cfg-output.cpp
Marcin Swiderski
marcin.sfider at gmail.com
Thu Sep 30 18:46:52 PDT 2010
Author: sfider
Date: Thu Sep 30 20:46:52 2010
New Revision: 115266
URL: http://llvm.org/viewvc/llvm-project?rev=115266&view=rev
Log:
Added generating CFGAutomaticObjDtors for exception variable in catch statement.
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=115266&r1=115265&r2=115266&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Sep 30 20:46:52 2010
@@ -2154,6 +2154,18 @@
// CXXCatchStmt are treated like labels, so they are the first statement in a
// block.
+ // Save local scope position because in case of exception variable ScopePos
+ // won't be restored when traversing AST.
+ SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
+
+ // Create local scope for possible exception variable.
+ // Store scope position. Add implicit destructor.
+ if (VarDecl* VD = CS->getExceptionDecl()) {
+ LocalScope::const_iterator BeginScopePos = ScopePos;
+ addLocalScopeForVarDecl(VD);
+ addAutomaticObjDtors(ScopePos, BeginScopePos, CS);
+ }
+
if (CS->getHandlerBlock())
addStmt(CS->getHandlerBlock());
Modified: cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp?rev=115266&r1=115265&r2=115266&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp (original)
+++ cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp Thu Sep 30 20:46:52 2010
@@ -138,6 +138,18 @@
A f;
}
+void test_catch_const_ref() {
+ try {
+ } catch (const A& e) {
+ }
+}
+
+void test_catch_copy() {
+ try {
+ } catch (A e) {
+ }
+}
+
// CHECK: [ B2 (ENTRY) ]
// CHECK: Predecessors (0):
// CHECK: Successors (1): B1
@@ -726,3 +738,32 @@
// CHECK: [ B0 (EXIT) ]
// CHECK: Predecessors (2): B1 B5
// CHECK: Successors (0):
+// CHECK: [ B3 (ENTRY) ]
+// CHECK: Predecessors (0):
+// CHECK: Successors (1): B0
+// CHECK: [ B1 ]
+// CHECK: T: try ...
+// CHECK: Predecessors (0):
+// CHECK: Successors (2): B2 B0
+// CHECK: [ B2 ]
+// CHECK: catch (const A &e):
+// CHECK: Predecessors (1): B1
+// CHECK: Successors (1): B0
+// CHECK: [ B0 (EXIT) ]
+// CHECK: Predecessors (3): B2 B1 B3
+// CHECK: Successors (0):
+// CHECK: [ B3 (ENTRY) ]
+// CHECK: Predecessors (0):
+// CHECK: Successors (1): B0
+// CHECK: [ B1 ]
+// CHECK: T: try ...
+// CHECK: Predecessors (0):
+// CHECK: Successors (2): B2 B0
+// CHECK: [ B2 ]
+// CHECK: catch (A e):
+// CHECK: 1: .~A() (Implicit destructor)
+// CHECK: Predecessors (1): B1
+// CHECK: Successors (1): B0
+// CHECK: [ B0 (EXIT) ]
+// CHECK: Predecessors (3): B2 B1 B3
+// CHECK: Successors (0):
More information about the cfe-commits
mailing list