From: Raphael Isemann Date: Mon, 20 Aug 2018 22:13:24 +0000 (+0000) Subject: [ASTImporter] Add test for C++'s try/catch statements. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e20516350f5e2062f0b5f49efb56acd94c83e5e4;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340220 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Import/cxx-try-catch/Inputs/F.cpp b/test/Import/cxx-try-catch/Inputs/F.cpp new file mode 100644 index 0000000000..4e06f3599b --- /dev/null +++ b/test/Import/cxx-try-catch/Inputs/F.cpp @@ -0,0 +1,18 @@ +void f() { + try { + } catch (...) { + } + + try { + } catch (int) { + } + + try { + } catch (int varname) { + } + + try { + } catch (int varname1) { + } catch (long varname2) { + } +} diff --git a/test/Import/cxx-try-catch/test.cpp b/test/Import/cxx-try-catch/test.cpp new file mode 100644 index 0000000000..079e35b3e7 --- /dev/null +++ b/test/Import/cxx-try-catch/test.cpp @@ -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: <> +// 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(); +} diff --git a/tools/clang-import-test/clang-import-test.cpp b/tools/clang-import-test/clang-import-test.cpp index ff14f62574..f64f0f8042 100644 --- a/tools/clang-import-test/clang-import-test.cpp +++ b/tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,8 @@ std::unique_ptr BuildCompilerInstance() { 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);