[PATCH] D29859: Make Lit tests C++11 compatible - nounwind noexcept

Charles Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 10 17:53:17 PST 2017


tigerleapgorge created this revision.

I am continuing to make Lit tests C++11 compatible.
There are 3 tests in this patch (previously in https://reviews.llvm.org/D24812).
All 3 tests relate to C++11 destructors being nonthrowing by default.

CodeGenCXX/linetable-cleanup.cpp

  C::~C() has an extra “nounwind” attribute in C++11.
  Relaxed the CHECK pattern matching for possible existence of “ #[0-9]”.

IR:

  C++98: call void @_ZN1CD1Ev(%class.C* %c), !dbg !21
  C++11: call void @_ZN1CD1Ev(%class.C* %c) #2, !dbg !21
         attributes #2 = { nounwind }

CodeGenCXX/lpad-linetable.cpp

  The purpose of this test is to verify landingpad line numbers when catching
  any exceptions thrown by the destructors for “longs” and “shorts” as they go out of scope.
  In C++11, “longs” and “short”’s destructors are nonthrowing, so no landingpad is generated.
  And since the purpose of this test is to verify for landingpad line table, I have restricted this test to C++98.
  
  C++11 IR:
     ~std::_Vector_base<long, std::allocator<long> >() noexcept
     ~std::_Vector_base<short, std::allocator<short> >() noexcept 

Index/comment-cplus-decls.cpp

  In C++11, ~Test() is nonthrowing.
  IR:
    C++98: <Declaration>~Test()</Declaration>
    C++11: <Declaration>~Test() noexcept</Declaration>


https://reviews.llvm.org/D29859

Files:
  test/CodeGenCXX/linetable-cleanup.cpp
  test/CodeGenCXX/lpad-linetable.cpp
  test/Index/comment-cplus-decls.cpp


Index: test/Index/comment-cplus-decls.cpp
===================================================================
--- test/Index/comment-cplus-decls.cpp
+++ test/Index/comment-cplus-decls.cpp
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// RUN: FileCheck %s -check-prefix=WRONG < %t/98
+// RUN: FileCheck %s -check-prefix=WRONG < %t/11
 // WRONG-NOT: CommentXMLInvalid
 // rdar://12378714
 
@@ -42,7 +48,7 @@
 // CHECK: <Declaration>class Test {}</Declaration>
 // CHECK: <Declaration>Test() : reserved(new Test::data()) {}</Declaration>
 // CHECK: <Declaration>unsigned int getID() const</Declaration>
-// CHECK: <Declaration>~Test()</Declaration>
+// CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration>
 // CHECK: <Declaration>Test::data *reserved</Declaration>
 
 
Index: test/CodeGenCXX/lpad-linetable.cpp
===================================================================
--- test/CodeGenCXX/lpad-linetable.cpp
+++ test/CodeGenCXX/lpad-linetable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++98 %s -o - | FileCheck %s
 // The landing pad should have the line number of the closing brace of the function.
 // rdar://problem/13888152
 // CHECK: ret i32
Index: test/CodeGenCXX/linetable-cleanup.cpp
===================================================================
--- test/CodeGenCXX/linetable-cleanup.cpp
+++ test/CodeGenCXX/linetable-cleanup.cpp
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++11 %s -o - | FileCheck %s
 
 // Check the line numbers for cleanup code with EH in combination with
 // simple return expressions.
 
 // CHECK: define {{.*}}foo
-// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]
+// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}){{( #[0-9])?}}, !dbg ![[RET:[0-9]+]]
 // CHECK: ret i32 0, !dbg ![[RET]]
 
 // CHECK: define {{.*}}bar


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29859.88074.patch
Type: text/x-patch
Size: 2980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170211/e0bfd0ca/attachment.bin>


More information about the cfe-commits mailing list