r340220 - [ASTImporter] Add test for C++'s try/catch statements.

Raphael Isemann via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 20 15:13:24 PDT 2018


Author: teemperor
Date: Mon Aug 20 15:13:24 2018
New Revision: 340220

URL: http://llvm.org/viewvc/llvm-project?rev=340220&view=rev
Log:
[ASTImporter] Add test for C++'s try/catch statements.

Summary: Also enable exceptions in clang-import-test so that we can parse the test files.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

Differential Revision: https://reviews.llvm.org/D50978

Added:
    cfe/trunk/test/Import/cxx-try-catch/
    cfe/trunk/test/Import/cxx-try-catch/Inputs/
    cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp
    cfe/trunk/test/Import/cxx-try-catch/test.cpp
Modified:
    cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Added: cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp?rev=340220&view=auto
==============================================================================
--- cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp Mon Aug 20 15:13:24 2018
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}

Added: cfe/trunk/test/Import/cxx-try-catch/test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/test.cpp?rev=340220&view=auto
==============================================================================
--- cfe/trunk/test/Import/cxx-try-catch/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-try-catch/test.cpp Mon Aug 20 15:13:24 2018
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <<NULL>>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=340220&r1=340219&r2=340220&view=diff
==============================================================================
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Mon Aug 20 15:13:24 2018
@@ -194,6 +194,8 @@ std::unique_ptr<CompilerInstance> BuildC
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);




More information about the cfe-commits mailing list