summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2018-08-20 22:13:24 +0000
committerRaphael Isemann <teemperor@gmail.com>2018-08-20 22:13:24 +0000
commit79d50a04c060af23642cc1f290299defb3032405 (patch)
treed59b6bc24053ed72d8ad62c663e3a44beba16dca
parent0e45df4c0ea6658f44c00c9af6303e81dbdc0886 (diff)
downloadbcm5719-llvm-79d50a04c060af23642cc1f290299defb3032405.tar.gz
bcm5719-llvm-79d50a04c060af23642cc1f290299defb3032405.zip
[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 llvm-svn: 340220
-rw-r--r--clang/test/Import/cxx-try-catch/Inputs/F.cpp18
-rw-r--r--clang/test/Import/cxx-try-catch/test.cpp39
-rw-r--r--clang/tools/clang-import-test/clang-import-test.cpp2
3 files changed, 59 insertions, 0 deletions
diff --git a/clang/test/Import/cxx-try-catch/Inputs/F.cpp b/clang/test/Import/cxx-try-catch/Inputs/F.cpp
new file mode 100644
index 00000000000..4e06f3599bb
--- /dev/null
+++ b/clang/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/clang/test/Import/cxx-try-catch/test.cpp b/clang/test/Import/cxx-try-catch/test.cpp
new file mode 100644
index 00000000000..079e35b3e7d
--- /dev/null
+++ b/clang/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: <<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();
+}
diff --git a/clang/tools/clang-import-test/clang-import-test.cpp b/clang/tools/clang-import-test/clang-import-test.cpp
index ff14f62574e..f64f0f8042d 100644
--- a/clang/tools/clang-import-test/clang-import-test.cpp
+++ b/clang/tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@ std::unique_ptr<CompilerInstance> 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);
OpenPOWER on IntegriCloud