This revision was automatically updated to reflect the committed changes. Closed by commit rC340220: [ASTImporter] Add test for C++'s try/catch statements. (authored by teemperor, committed by ).
Repository: rC Clang https://reviews.llvm.org/D50978 Files: test/Import/cxx-try-catch/Inputs/F.cpp test/Import/cxx-try-catch/test.cpp tools/clang-import-test/clang-import-test.cpp Index: tools/clang-import-test/clang-import-test.cpp =================================================================== --- tools/clang-import-test/clang-import-test.cpp +++ tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,8 @@ 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); Index: test/Import/cxx-try-catch/Inputs/F.cpp =================================================================== --- test/Import/cxx-try-catch/Inputs/F.cpp +++ 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) { + } +} Index: test/Import/cxx-try-catch/test.cpp =================================================================== --- test/Import/cxx-try-catch/test.cpp +++ 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(); +}
Index: tools/clang-import-test/clang-import-test.cpp =================================================================== --- tools/clang-import-test/clang-import-test.cpp +++ tools/clang-import-test/clang-import-test.cpp @@ -194,6 +194,8 @@ 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); Index: test/Import/cxx-try-catch/Inputs/F.cpp =================================================================== --- test/Import/cxx-try-catch/Inputs/F.cpp +++ 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) { + } +} Index: test/Import/cxx-try-catch/test.cpp =================================================================== --- test/Import/cxx-try-catch/test.cpp +++ 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(); +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits