[PATCH] ASTDumper: fix dump of CXXCatchStmt

Pavel Labath labath at google.com
Wed Sep 4 07:26:14 PDT 2013


  - add test

http://llvm-reviews.chandlerc.com/D1596

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1596?vs=4019&id=4026#toc

Files:
  lib/AST/ASTDumper.cpp
  test/Misc/ast-dump-stmt.cpp

Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -249,6 +249,7 @@
     void VisitAttributedStmt(const AttributedStmt *Node);
     void VisitLabelStmt(const LabelStmt *Node);
     void VisitGotoStmt(const GotoStmt *Node);
+    void VisitCXXCatchStmt(const CXXCatchStmt *Node);
 
     // Exprs
     void VisitExpr(const Expr *Node);
@@ -1461,6 +1462,11 @@
   dumpPointer(Node->getLabel());
 }
 
+void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {
+  VisitStmt(Node);
+  dumpDecl(Node->getExceptionDecl());
+}
+
 //===----------------------------------------------------------------------===//
 //  Expr dumping methods.
 //===----------------------------------------------------------------------===//
Index: test/Misc/ast-dump-stmt.cpp
===================================================================
--- test/Misc/ast-dump-stmt.cpp
+++ test/Misc/ast-dump-stmt.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fcxx-exceptions -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
 
 namespace n {
 void function() {}
@@ -12,3 +12,29 @@
   Variable = 4;
 // CHECK:       DeclRefExpr{{.*}} (UsingShadow{{.*}}Variable
 }
+
+// CHECK: FunctionDecl {{.*}} TestCatch1
+void TestCatch1() {
+// CHECK:       CXXTryStmt
+// CHECK-NEXT:    CompoundStmt
+  try {
+  }
+// CHECK-NEXT:    CXXCatchStmt
+// CHECK-NEXT:      VarDecl {{.*}} x
+// CHECK-NEXT:      CompoundStmt
+  catch (int x) {
+  }
+}
+
+// CHECK: FunctionDecl {{.*}} TestCatch2
+void TestCatch2() {
+// CHECK:       CXXTryStmt
+// CHECK-NEXT:    CompoundStmt
+  try {
+  }
+// CHECK-NEXT:    CXXCatchStmt
+// CHECK-NEXT:      NULL
+// CHECK-NEXT:      CompoundStmt
+  catch (...) {
+  }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1596.2.patch
Type: text/x-patch
Size: 1856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130904/62a632bd/attachment.bin>


More information about the cfe-commits mailing list