diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-18 14:59:57 +0000 |
| commit | b3d5a323a5ca92ea73443499cee2f15db1ff0fb3 (patch) | |
| tree | 60a1694bec5a44d15456acc880cb2f91619f66aa /test/CodeGenCXX | |
| parent | 8f57cb0305232cb53fff00ef151ca716766f3437 (diff) | |
Notes
Diffstat (limited to 'test/CodeGenCXX')
64 files changed, 1439 insertions, 602 deletions
diff --git a/test/CodeGenCXX/PR5050-constructor-conversion.cpp b/test/CodeGenCXX/PR5050-constructor-conversion.cpp index e5f722c513de..c0b53d5f6e55 100644 --- a/test/CodeGenCXX/PR5050-constructor-conversion.cpp +++ b/test/CodeGenCXX/PR5050-constructor-conversion.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s struct A { A(const A&, int i1 = 1); }; diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp index 5b6bc2e5b511..2f82872d6c9e 100644 --- a/test/CodeGenCXX/array-construction.cpp +++ b/test/CodeGenCXX/array-construction.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/array-operator-delete-call.cpp b/test/CodeGenCXX/array-operator-delete-call.cpp new file mode 100644 index 000000000000..c23d33632a38 --- /dev/null +++ b/test/CodeGenCXX/array-operator-delete-call.cpp @@ -0,0 +1,63 @@ +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s + +extern "C" int printf(...); + +int count; + +struct S { + S() : iS (++count) { printf("S::S(%d)\n", iS); } + ~S() { printf("S::~S(%d)\n", iS); } + int iS; +}; + +struct V { + V() : iV (++count) { printf("V::V(%d)\n", iV); } + virtual ~V() { printf("V::~V(%d)\n", iV); } + int iV; +}; + +struct COST +{ + S *cost; + V *vcost; + unsigned *cost_val; + + ~COST(); + COST(); +}; + + +COST::COST() +{ + cost = new S[3]; + vcost = new V[4]; + cost_val = new unsigned[10]; +} + +COST::~COST() +{ + if (cost) { + delete [] cost; + } + if (vcost) { + delete [] vcost; + } + if (cost_val) + delete [] cost_val; +} + +COST c1; + +int main() +{ + COST c3; +} +COST c2; + +// CHECK-LP64: call __ZdaPv + +// CHECK-LP32: call L__ZdaPv + diff --git a/test/CodeGenCXX/array-value-initialize.cpp b/test/CodeGenCXX/array-value-initialize.cpp new file mode 100644 index 000000000000..f041bc584b12 --- /dev/null +++ b/test/CodeGenCXX/array-value-initialize.cpp @@ -0,0 +1,28 @@ +// RUN: clang-cc -emit-llvm -o - %s + +// PR5463 +extern "C" int printf(...); + +struct S { + double filler; +}; + +struct Foo { + Foo(void) : bar_(), dbar_(), sbar_() { + for (int i = 0; i < 5; i++) { + printf("bar_[%d] = %d\n", i, bar_[i]); + printf("dbar_[%d] = %f\n", i, dbar_[i]); + printf("sbar_[%d].filler = %f\n", i, sbar_[i].filler); + } + } + + int bar_[5]; + double dbar_[5]; + S sbar_[5]; +}; + +int main(void) +{ + Foo a; +} + diff --git a/test/CodeGenCXX/assign-operator.cpp b/test/CodeGenCXX/assign-operator.cpp new file mode 100644 index 000000000000..3e0be4519438 --- /dev/null +++ b/test/CodeGenCXX/assign-operator.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc %s -emit-llvm-only -verify + +class x { +int operator=(int); +}; +void a() { + x a; + a = 1u; +} diff --git a/test/CodeGenCXX/attr.cpp b/test/CodeGenCXX/attr.cpp index 8077b7839d88..695e9e72f1a1 100644 --- a/test/CodeGenCXX/attr.cpp +++ b/test/CodeGenCXX/attr.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -O0 -S %s -o %t.s && +// RUN: clang-cc -triple x86_64-apple-darwin -O0 -S %s -o %t.s // RUN: FileCheck --input-file=%t.s %s int foo() __attribute__((aligned(1024))); diff --git a/test/CodeGenCXX/call-arg-zero-temp.cpp b/test/CodeGenCXX/call-arg-zero-temp.cpp index 2c44f69d975e..e066927ad702 100644 --- a/test/CodeGenCXX/call-arg-zero-temp.cpp +++ b/test/CodeGenCXX/call-arg-zero-temp.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/cast-conversion.cpp b/test/CodeGenCXX/cast-conversion.cpp index f571f549d094..fa8487ac66b9 100644 --- a/test/CodeGenCXX/cast-conversion.cpp +++ b/test/CodeGenCXX/cast-conversion.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s struct A { A(int); diff --git a/test/CodeGenCXX/class-layout.cpp b/test/CodeGenCXX/class-layout.cpp index 7255d3e4f94d..7663d2e541b2 100644 --- a/test/CodeGenCXX/class-layout.cpp +++ b/test/CodeGenCXX/class-layout.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc %s -emit-llvm -o %t && +// RUN: clang-cc %s -emit-llvm -o %t // An extra byte shoudl be allocated for an empty class. // RUN: grep '%.truct.A = type { i8 }' %t diff --git a/test/CodeGenCXX/constructor-conversion.cpp b/test/CodeGenCXX/constructor-conversion.cpp index 980b230118d8..dcc9535315ab 100644 --- a/test/CodeGenCXX/constructor-conversion.cpp +++ b/test/CodeGenCXX/constructor-conversion.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-default-arg.cpp b/test/CodeGenCXX/constructor-default-arg.cpp index 7e6a7cd8f71a..c494149d1110 100644 --- a/test/CodeGenCXX/constructor-default-arg.cpp +++ b/test/CodeGenCXX/constructor-default-arg.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-for-array-members.cpp b/test/CodeGenCXX/constructor-for-array-members.cpp index fbb13e0aa3c2..5160a8975488 100644 --- a/test/CodeGenCXX/constructor-for-array-members.cpp +++ b/test/CodeGenCXX/constructor-for-array-members.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/constructor-template.cpp b/test/CodeGenCXX/constructor-template.cpp index 8c4f2c912709..66ec9eac212c 100644 --- a/test/CodeGenCXX/constructor-template.cpp +++ b/test/CodeGenCXX/constructor-template.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s // PR4826 struct A { diff --git a/test/CodeGenCXX/conversion-function.cpp b/test/CodeGenCXX/conversion-function.cpp index 0bfd4af7e265..c93587675ba1 100644 --- a/test/CodeGenCXX/conversion-function.cpp +++ b/test/CodeGenCXX/conversion-function.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); struct S { diff --git a/test/CodeGenCXX/convert-to-fptr.cpp b/test/CodeGenCXX/convert-to-fptr.cpp index c0bd2f7b856e..7cc8c08444aa 100644 --- a/test/CodeGenCXX/convert-to-fptr.cpp +++ b/test/CodeGenCXX/convert-to-fptr.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/test/CodeGenCXX/copy-assign-synthesis-1.cpp index d4a93afefbfa..14fbe30703d3 100644 --- a/test/CodeGenCXX/copy-assign-synthesis-1.cpp +++ b/test/CodeGenCXX/copy-assign-synthesis-1.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-assign-synthesis.cpp b/test/CodeGenCXX/copy-assign-synthesis.cpp index f9baa8f03f3c..65a84f414a93 100644 --- a/test/CodeGenCXX/copy-assign-synthesis.cpp +++ b/test/CodeGenCXX/copy-assign-synthesis.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -emit-llvm -o %t %s && +// RUN: clang-cc -emit-llvm -o %t %s // RUN: grep "_ZN1XaSERK1X" %t | count 0 extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-constructor-elim.cpp b/test/CodeGenCXX/copy-constructor-elim.cpp index daef92cdb767..953effe77af1 100644 --- a/test/CodeGenCXX/copy-constructor-elim.cpp +++ b/test/CodeGenCXX/copy-constructor-elim.cpp @@ -1,7 +1,6 @@ -// RUN: clang-cc -emit-llvm -o %t %s && -// RUN: grep "_ZN1CC1ERK1C" %t | count 0 && -// RUN: grep "_ZN1SC1ERK1S" %t | count 0 && -// RUN: true +// RUN: clang-cc -emit-llvm -o %t %s +// RUN: grep "_ZN1CC1ERK1C" %t | count 0 +// RUN: grep "_ZN1SC1ERK1S" %t | count 0 extern "C" int printf(...); diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp index 47971afe61d4..3b8f7821abcf 100644 --- a/test/CodeGenCXX/copy-constructor-synthesis.cpp +++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); @@ -45,6 +44,8 @@ struct X : M, N, P { // ... const char *name; unsigned bf1 : 8; unsigned bf2 : 16; + int arr[2]; + _Complex float complex; union { int au_i1; diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp new file mode 100644 index 000000000000..b89435a99044 --- /dev/null +++ b/test/CodeGenCXX/debug-info.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -emit-llvm-only -g +template<typename T> struct Identity { + typedef T Type; +}; + +void f(Identity<int>::Type a) {} +void f(Identity<int> a) {} +void f(int& a) { } + +template<typename T> struct A { + A<T> *next; +}; +void f(A<int>) { } diff --git a/test/CodeGenCXX/decl-ref-init.cpp b/test/CodeGenCXX/decl-ref-init.cpp index 27d200f4635b..fd93b7b21e04 100644 --- a/test/CodeGenCXX/decl-ref-init.cpp +++ b/test/CodeGenCXX/decl-ref-init.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s struct A {}; diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp index 8385aff6291c..0ec5b582c95b 100644 --- a/test/CodeGenCXX/default-arg-temps.cpp +++ b/test/CodeGenCXX/default-arg-temps.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 && +// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 struct T { T(); @@ -14,8 +14,8 @@ public: }; void g() { - // RUN: grep "call void @_ZN1TC1Ev" %t | count 4 && - // RUN: grep "call void @_ZN1TD1Ev" %t | count 4 && + // RUN: grep "call void @_ZN1TC1Ev" %t | count 4 + // RUN: grep "call void @_ZN1TD1Ev" %t | count 4 f(); f(); diff --git a/test/CodeGenCXX/default-arguments.cpp b/test/CodeGenCXX/default-arguments.cpp new file mode 100644 index 000000000000..5028ce99c7b7 --- /dev/null +++ b/test/CodeGenCXX/default-arguments.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin10 + +// PR5484 +namespace PR5484 { +struct A { }; +extern A a; + +void f(const A & = a); + +void g() { + f(); +} +} diff --git a/test/CodeGenCXX/default-constructor-default-argument.cpp b/test/CodeGenCXX/default-constructor-default-argument.cpp new file mode 100644 index 000000000000..f53732e471fe --- /dev/null +++ b/test/CodeGenCXX/default-constructor-default-argument.cpp @@ -0,0 +1,8 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +// Check that call to constructor for struct A is generated correctly. +struct A { A(int x = 2); }; +struct B : public A {}; +B x; + +// CHECK: call void @_ZN1AC1Ei diff --git a/test/CodeGenCXX/default-constructor-for-members.cpp b/test/CodeGenCXX/default-constructor-for-members.cpp index 2d04bc941427..d972d63d3cbc 100644 --- a/test/CodeGenCXX/default-constructor-for-members.cpp +++ b/test/CodeGenCXX/default-constructor-for-members.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/default-destructor-synthesis.cpp b/test/CodeGenCXX/default-destructor-synthesis.cpp index 9cc802c85dfa..fef9c03d7ac1 100644 --- a/test/CodeGenCXX/default-destructor-synthesis.cpp +++ b/test/CodeGenCXX/default-destructor-synthesis.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -O0 -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 -input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -O0 -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 -input-file=%t-32.s %s extern "C" int printf(...); diff --git a/test/CodeGenCXX/delete-two-arg.cpp b/test/CodeGenCXX/delete-two-arg.cpp new file mode 100644 index 000000000000..a5b18ba06fc3 --- /dev/null +++ b/test/CodeGenCXX/delete-two-arg.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -triple i686-pc-linux-gnu %s -o - -emit-llvm -verify | FileCheck %s + +struct A { void operator delete(void*,__typeof(sizeof(int))); int x; }; +void a(A* x) { delete x; } + +// CHECK: call void @_ZN1AdlEPvj(i8* %0, i32 4) diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index 9e3feefefeda..78c83cf0df62 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc %s -emit-llvm -o %t && +// RUN: clang-cc %s -emit-llvm -o %t void t1(int *a) { delete a; diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp index 0c890195119f..70948b0ff933 100644 --- a/test/CodeGenCXX/derived-to-base-conv.cpp +++ b/test/CodeGenCXX/derived-to-base-conv.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s extern "C" int printf(...); extern "C" void exit(int); diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp index 44d2b2936864..a196c13f8f42 100644 --- a/test/CodeGenCXX/destructors.cpp +++ b/test/CodeGenCXX/destructors.cpp @@ -28,3 +28,17 @@ class A1 { }; template<> A1<char>::~A1(); + +// PR5529 +namespace PR5529 { + struct A { + ~A(); + }; + + A::~A() { } + struct B : A { + virtual ~B(); + }; + + B::~B() {} +} diff --git a/test/CodeGenCXX/dyncast.cpp b/test/CodeGenCXX/dyncast.cpp new file mode 100644 index 000000000000..4719f80a5b41 --- /dev/null +++ b/test/CodeGenCXX/dyncast.cpp @@ -0,0 +1,414 @@ +// RUN: clang-cc -I%S -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll +// RUN: FileCheck -check-prefix LL --input-file=%t.ll %s + +#include <typeinfo> + +class test1_A { virtual void f() { } }; +class test1_B { virtual void g() { } }; +class test1_D : public virtual test1_A, private test1_B {}; +class test1_E : public test1_D, public test1_B {}; +class test1_F : public test1_E, public test1_D {}; + +extern test1_D test1_d; +extern test1_F test1_f; + +extern "C" int printf(const char *str...); + +#define S(V, N) if (V) printf("PASS: %d\n", N); else printf("FAIL: %d\n", N) + +void test1() { + test1_B* bp = (test1_B*)&test1_d; + test1_A* ap = &test1_d; + // This throws + // test1_D& dr = dynamic_cast<D&>(*bp); + test1_D* dp = dynamic_cast<test1_D*>(bp); + S(dp == 0, 1); + ap = dynamic_cast<test1_A*>(bp); + S(ap == 0, 2); + bp = dynamic_cast<test1_B*>(ap); + S(bp == 0, 3); + ap = dynamic_cast<test1_A*>(&test1_d); + S(ap != 0, 4); + // FIXME: Doesn't work yet, gcc fails this at compile time. We'd need access + // control for this to work. + // bp = dynamic_cast<test1_B*>(&test1_d); + // S(bp == 0, 5); + { + test1_A* ap = &test1_f; + S(ap != 0, 6); + test1_D* dp = dynamic_cast<test1_D*>(ap); + S(dp == 0, 7); + // cast from virtual base + test1_E* ep1 = dynamic_cast<test1_E*>(ap); + S(ep1 != 0, 8); + } + dp = dynamic_cast<test1_D*>(&test1_d); + S(dp == &test1_d, 9); + const test1_D *cdp = dynamic_cast<const test1_D*>(&test1_d); + S(cdp == &test1_d, 10); + dp = dynamic_cast<test1_D*>((test1_A*)0); + S(dp == 0, 11); + ap = dynamic_cast<test1_A*>(&test1_d); + S(ap == (test1_A*)&test1_d, 12); + test1_E* ep = dynamic_cast<test1_E*>(&test1_f); + S(ep == (test1_E*)&test1_f, 13); + void *vp = dynamic_cast<void*>(ap); + S(vp == &test1_d, 14); + const void *cvp = dynamic_cast<const void*>(ap); + S(cvp == &test1_d, 15); +} + +// CHECK-LL: define void @_Z5test1v() nounwind { +// CHECK-LL-NEXT:entry: +// CHECK-LL-NEXT: %bp = alloca %class.test1_A*, align 8 +// CHECK-LL-NEXT: %ap = alloca %class.test1_A*, align 8 +// CHECK-LL-NEXT: %dp = alloca %class.test1_D*, align 8 +// CHECK-LL-NEXT: %ap37 = alloca %class.test1_A*, align 8 +// CHECK-LL-NEXT: %dp53 = alloca %class.test1_D*, align 8 +// CHECK-LL-NEXT: %ep1 = alloca %class.test1_E*, align 8 +// CHECK-LL-NEXT: %cdp = alloca %class.test1_D*, align 8 +// CHECK-LL-NEXT: %ep = alloca %class.test1_E*, align 8 +// CHECK-LL-NEXT: %vp = alloca i8*, align 8 +// CHECK-LL-NEXT: %cvp = alloca i8*, align 8 +// CHECK-LL-NEXT: br i1 false, label %cast.null, label %cast.notnull +// CHECK-LL: cast.notnull: +// CHECK-LL-NEXT: br label %cast.end +// CHECK-LL: cast.null: +// CHECK-LL-NEXT: br label %cast.end +// CHECK-LL: cast.end: +// CHECK-LL-NEXT: %0 = phi %class.test1_A* [ bitcast (%class.test1_D* @test1_d to %class.test1_A*), %cast.notnull ], [ null, %cast.null ] +// CHECK-LL-NEXT: store %class.test1_A* %0, %class.test1_A** %bp +// CHECK-LL-NEXT: br i1 false, label %cast.null2, label %cast.notnull1 +// CHECK-LL: cast.notnull1: +// CHECK-LL-NEXT: %vtable = load i8** bitcast (%class.test1_D* @test1_d to i8**) +// CHECK-LL-NEXT: %vbase.offset.ptr = getelementptr i8* %vtable, i64 -24 +// CHECK-LL-NEXT: %1 = bitcast i8* %vbase.offset.ptr to i64* +// CHECK-LL-NEXT: %vbase.offset = load i64* %1 +// CHECK-LL-NEXT: %add.ptr = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 %vbase.offset +// CHECK-LL-NEXT: %2 = bitcast i8* %add.ptr to %class.test1_A* +// CHECK-LL-NEXT: br label %cast.end3 +// CHECK-LL: cast.null2: +// CHECK-LL-NEXT: br label %cast.end3 +// CHECK-LL: cast.end3: +// CHECK-LL-NEXT: %3 = phi %class.test1_A* [ %2, %cast.notnull1 ], [ null, %cast.null2 ] +// CHECK-LL-NEXT: store %class.test1_A* %3, %class.test1_A** %ap +// CHECK-LL-NEXT: %tmp = load %class.test1_A** %bp +// CHECK-LL-NEXT: %4 = icmp ne %class.test1_A* %tmp, null +// CHECK-LL-NEXT: br i1 %4, label %5, label %9 +// CHECK-LL: ; <label>:5 +// CHECK-LL-NEXT: %6 = bitcast %class.test1_A* %tmp to i8* +// CHECK-LL-NEXT: %7 = call i8* @__dynamic_cast(i8* %6, i8* bitcast (i8** @_ZTI7test1_B to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1) +// CHECK-LL-NEXT: %8 = bitcast i8* %7 to %class.test1_D* +// CHECK-LL-NEXT: br label %10 +// CHECK-LL: ; <label>:9 +// CHECK-LL-NEXT: br label %10 +// CHECK-LL: ; <label>:10 +// CHECK-LL-NEXT: %11 = phi %class.test1_D* [ %8, %5 ], [ null, %9 ] +// CHECK-LL-NEXT: store %class.test1_D* %11, %class.test1_D** %dp +// CHECK-LL-NEXT: %tmp4 = load %class.test1_D** %dp +// CHECK-LL-NEXT: %cmp = icmp eq %class.test1_D* %tmp4, null +// CHECK-LL-NEXT: br i1 %cmp, label %if.then, label %if.else +// CHECK-LL: if.then: +// CHECK-LL-NEXT: %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 1) +// CHECK-LL-NEXT: br label %if.end +// CHECK-LL: if.else: +// CHECK-LL-NEXT: %call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 1) +// CHECK-LL-NEXT: br label %if.end +// CHECK-LL: if.end: +// CHECK-LL-NEXT: %tmp6 = load %class.test1_A** %bp +// CHECK-LL-NEXT: %12 = icmp ne %class.test1_A* %tmp6, null +// CHECK-LL-NEXT: br i1 %12, label %13, label %17 +// CHECK-LL: ; <label>:13 +// CHECK-LL-NEXT: %14 = bitcast %class.test1_A* %tmp6 to i8* +// CHECK-LL-NEXT: %15 = call i8* @__dynamic_cast(i8* %14, i8* bitcast (i8** @_ZTI7test1_B to i8*), i8* bitcast (i8** @_ZTI7test1_A to i8*), i64 -1) +// CHECK-LL-NEXT: %16 = bitcast i8* %15 to %class.test1_A* +// CHECK-LL-NEXT: br label %18 +// CHECK-LL: ; <label>:17 +// CHECK-LL-NEXT: br label %18 +// CHECK-LL: ; <label>:18 +// CHECK-LL-NEXT: %19 = phi %class.test1_A* [ %16, %13 ], [ null, %17 ] +// CHECK-LL-NEXT: store %class.test1_A* %19, %class.test1_A** %ap +// CHECK-LL-NEXT: %tmp7 = load %class.test1_A** %ap +// CHECK-LL-NEXT: %cmp8 = icmp eq %class.test1_A* %tmp7, null +// CHECK-LL-NEXT: br i1 %cmp8, label %if.then9, label %if.else11 +// CHECK-LL: if.then9: +// CHECK-LL-NEXT: %call10 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 2) +// CHECK-LL-NEXT: br label %if.end13 +// CHECK-LL: if.else11: +// CHECK-LL-NEXT: %call12 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 2) +// CHECK-LL-NEXT: br label %if.end13 +// CHECK-LL: if.end13: +// CHECK-LL-NEXT: %tmp14 = load %class.test1_A** %ap +// CHECK-LL-NEXT: %20 = icmp ne %class.test1_A* %tmp14, null +// CHECK-LL-NEXT: br i1 %20, label %21, label %25 +// CHECK-LL: ; <label>:21 +// CHECK-LL-NEXT: %22 = bitcast %class.test1_A* %tmp14 to i8* +// CHECK-LL-NEXT: %23 = call i8* @__dynamic_cast(i8* %22, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_B to i8*), i64 -1) +// CHECK-LL-NEXT: %24 = bitcast i8* %23 to %class.test1_A* +// CHECK-LL-NEXT: br label %26 +// CHECK-LL: ; <label>:25 +// CHECK-LL-NEXT: br label %26 +// CHECK-LL: ; <label>:26 +// CHECK-LL-NEXT: %27 = phi %class.test1_A* [ %24, %21 ], [ null, %25 ] +// CHECK-LL-NEXT: store %class.test1_A* %27, %class.test1_A** %bp +// CHECK-LL-NEXT: %tmp15 = load %class.test1_A** %bp +// CHECK-LL-NEXT: %cmp16 = icmp eq %class.test1_A* %tmp15, null +// CHECK-LL-NEXT: br i1 %cmp16, label %if.then17, label %if.else19 +// CHECK-LL: if.then17: +// CHECK-LL-NEXT: %call18 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 3) +// CHECK-LL-NEXT: br label %if.end21 +// CHECK-LL: if.else19: +// CHECK-LL-NEXT: %call20 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 3) +// CHECK-LL-NEXT: br label %if.end21 +// CHECK-LL: if.end21: +// CHECK-LL-NEXT: br i1 false, label %cast.null27, label %cast.notnull22 +// CHECK-LL: cast.notnull22: +// CHECK-LL-NEXT: %vtable23 = load i8** bitcast (%class.test1_D* @test1_d to i8**) +// CHECK-LL-NEXT: %vbase.offset.ptr24 = getelementptr i8* %vtable23, i64 -24 +// CHECK-LL-NEXT: %28 = bitcast i8* %vbase.offset.ptr24 to i64* +// CHECK-LL-NEXT: %vbase.offset25 = load i64* %28 +// CHECK-LL-NEXT: %add.ptr26 = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 %vbase.offset25 +// CHECK-LL-NEXT: %29 = bitcast i8* %add.ptr26 to %class.test1_A* +// CHECK-LL-NEXT: br label %cast.end28 +// CHECK-LL: cast.null27: +// CHECK-LL-NEXT: br label %cast.end28 +// CHECK-LL: cast.end28: +// CHECK-LL-NEXT: %30 = phi %class.test1_A* [ %29, %cast.notnull22 ], [ null, %cast.null27 ] +// CHECK-LL-NEXT: store %class.test1_A* %30, %class.test1_A** %ap +// CHECK-LL-NEXT: %tmp29 = load %class.test1_A** %ap +// CHECK-LL-NEXT: %cmp30 = icmp ne %class.test1_A* %tmp29, null +// CHECK-LL-NEXT: br i1 %cmp30, label %if.then31, label %if.else33 +// CHECK-LL: if.then31: +// CHECK-LL-NEXT: %call32 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 4) +// CHECK-LL-NEXT: br label %if.end35 +// CHECK-LL: if.else33: +// CHECK-LL-NEXT: %call34 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 4) +// CHECK-LL-NEXT: br label %if.end35 +// CHECK-LL: if.end35: +// CHECK-LL-NEXT: br i1 false, label %cast.null43, label %cast.notnull38 +// CHECK-LL: cast.notnull38: +// CHECK-LL-NEXT: %vtable39 = load i8** bitcast (%class.test1_F* @test1_f to i8**) +// CHECK-LL-NEXT: %vbase.offset.ptr40 = getelementptr i8* %vtable39, i64 -24 +// CHECK-LL-NEXT: %31 = bitcast i8* %vbase.offset.ptr40 to i64* +// CHECK-LL-NEXT: %vbase.offset41 = load i64* %31 +// CHECK-LL-NEXT: %add.ptr42 = getelementptr i8* getelementptr inbounds (%class.test1_F* @test1_f, i32 0, i32 0, i32 0), i64 %vbase.offset41 +// CHECK-LL-NEXT: %32 = bitcast i8* %add.ptr42 to %class.test1_A* +// CHECK-LL-NEXT: br label %cast.end44 +// CHECK-LL: cast.null43: +// CHECK-LL-NEXT: br label %cast.end44 +// CHECK-LL: cast.end44: +// CHECK-LL-NEXT: %33 = phi %class.test1_A* [ %32, %cast.notnull38 ], [ null, %cast.null43 ] +// CHECK-LL-NEXT: store %class.test1_A* %33, %class.test1_A** %ap37 +// CHECK-LL-NEXT: %tmp45 = load %class.test1_A** %ap37 +// CHECK-LL-NEXT: %cmp46 = icmp ne %class.test1_A* %tmp45, null +// CHECK-LL-NEXT: br i1 %cmp46, label %if.then47, label %if.else49 +// CHECK-LL: if.then47: +// CHECK-LL-NEXT: %call48 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 6) +// CHECK-LL-NEXT: br label %if.end51 +// CHECK-LL: if.else49: +// CHECK-LL-NEXT: %call50 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 6) +// CHECK-LL-NEXT: br label %if.end51 +// CHECK-LL: if.end51: +// CHECK-LL-NEXT: %tmp54 = load %class.test1_A** %ap37 +// CHECK-LL-NEXT: %34 = icmp ne %class.test1_A* %tmp54, null +// CHECK-LL-NEXT: br i1 %34, label %35, label %39 +// CHECK-LL: ; <label>:35 +// CHECK-LL-NEXT: %36 = bitcast %class.test1_A* %tmp54 to i8* +// CHECK-LL-NEXT: %37 = call i8* @__dynamic_cast(i8* %36, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1) +// CHECK-LL-NEXT: %38 = bitcast i8* %37 to %class.test1_D* +// CHECK-LL-NEXT: br label %40 +// CHECK-LL: ; <label>:39 +// CHECK-LL-NEXT: br label %40 +// CHECK-LL: ; <label>:40 +// CHECK-LL-NEXT: %41 = phi %class.test1_D* [ %38, %35 ], [ null, %39 ] +// CHECK-LL-NEXT: store %class.test1_D* %41, %class.test1_D** %dp53 +// CHECK-LL-NEXT: %tmp55 = load %class.test1_D** %dp53 +// CHECK-LL-NEXT: %cmp56 = icmp eq %class.test1_D* %tmp55, null +// CHECK-LL-NEXT: br i1 %cmp56, label %if.then57, label %if.else59 +// CHECK-LL: if.then57: +// CHECK-LL-NEXT: %call58 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 7) +// CHECK-LL-NEXT: br label %if.end61 +// CHECK-LL: if.else59: +// CHECK-LL-NEXT: %call60 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 7) +// CHECK-LL-NEXT: br label %if.end61 +// CHECK-LL: if.end61: +// CHECK-LL-NEXT: %tmp63 = load %class.test1_A** %ap37 +// CHECK-LL-NEXT: %42 = icmp ne %class.test1_A* %tmp63, null +// CHECK-LL-NEXT: br i1 %42, label %43, label %47 +// CHECK-LL: ; <label>:43 +// CHECK-LL-NEXT: %44 = bitcast %class.test1_A* %tmp63 to i8* +// CHECK-LL-NEXT: %45 = call i8* @__dynamic_cast(i8* %44, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_E to i8*), i64 -1) +// CHECK-LL-NEXT: %46 = bitcast i8* %45 to %class.test1_E* +// CHECK-LL-NEXT: br label %48 +// CHECK-LL: ; <label>:47 +// CHECK-LL-NEXT: br label %48 +// CHECK-LL: ; <label>:48 +// CHECK-LL-NEXT: %49 = phi %class.test1_E* [ %46, %43 ], [ null, %47 ] +// CHECK-LL-NEXT: store %class.test1_E* %49, %class.test1_E** %ep1 +// CHECK-LL-NEXT: %tmp64 = load %class.test1_E** %ep1 +// CHECK-LL-NEXT: %cmp65 = icmp ne %class.test1_E* %tmp64, null +// CHECK-LL-NEXT: br i1 %cmp65, label %if.then66, label %if.else68 +// CHECK-LL: if.then66: +// CHECK-LL-NEXT: %call67 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 8) +// CHECK-LL-NEXT: br label %if.end70 +// CHECK-LL: if.else68: +// CHECK-LL-NEXT: %call69 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 8) +// CHECK-LL-NEXT: br label %if.end70 +// CHECK-LL: if.end70: +// CHECK-LL-NEXT: store %class.test1_D* @test1_d, %class.test1_D** %dp +// CHECK-LL-NEXT: %tmp71 = load %class.test1_D** %dp +// CHECK-LL-NEXT: %cmp72 = icmp eq %class.test1_D* %tmp71, @test1_d +// CHECK-LL-NEXT: br i1 %cmp72, label %if.then73, label %if.else75 +// CHECK-LL: if.then73: +// CHECK-LL-NEXT: %call74 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 9) +// CHECK-LL-NEXT: br label %if.end77 +// CHECK-LL: if.else75: +// CHECK-LL-NEXT: %call76 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 9) +// CHECK-LL-NEXT: br label %if.end77 +// CHECK-LL: if.end77: +// CHECK-LL-NEXT: store %class.test1_D* @test1_d, %class.test1_D** %cdp +// CHECK-LL-NEXT: %tmp79 = load %class.test1_D** %cdp +// CHECK-LL-NEXT: %cmp80 = icmp eq %class.test1_D* %tmp79, @test1_d +// CHECK-LL-NEXT: br i1 %cmp80, label %if.then81, label %if.else83 +// CHECK-LL: if.then81: +// CHECK-LL-NEXT: %call82 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 10) +// CHECK-LL-NEXT: br label %if.end85 +// CHECK-LL: if.else83: +// CHECK-LL-NEXT: %call84 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 10) +// CHECK-LL-NEXT: br label %if.end85 +// CHECK-LL: if.end85: +// CHECK-LL-NEXT: br i1 false, label %50, label %53 +// CHECK-LL: ; <label>:50 +// CHECK-LL-NEXT: %51 = call i8* @__dynamic_cast(i8* null, i8* bitcast (i8** @_ZTI7test1_A to i8*), i8* bitcast (i8** @_ZTI7test1_D to i8*), i64 -1) +// CHECK-LL-NEXT: %52 = bitcast i8* %51 to %class.test1_D* +// CHECK-LL-NEXT: br label %54 +// CHECK-LL: ; <label>:53 +// CHECK-LL-NEXT: br label %54 +// CHECK-LL: ; <label>:54 +// CHECK-LL-NEXT: %55 = phi %class.test1_D* [ %52, %50 ], [ null, %53 ] +// CHECK-LL-NEXT: store %class.test1_D* %55, %class.test1_D** %dp +// CHECK-LL-NEXT: %tmp86 = load %class.test1_D** %dp +// CHECK-LL-NEXT: %cmp87 = icmp eq %class.test1_D* %tmp86, null +// CHECK-LL-NEXT: br i1 %cmp87, label %if.then88, label %if.else90 +// CHECK-LL: if.then88: +// CHECK-LL-NEXT: %call89 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 11) +// CHECK-LL-NEXT: br label %if.end92 +// CHECK-LL: if.else90: +// CHECK-LL-NEXT: %call91 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 11) +// CHECK-LL-NEXT: br label %if.end92 +// CHECK-LL: if.end92: +// CHECK-LL-NEXT: br i1 false, label %cast.null98, label %cast.notnull93 +// CHECK-LL: cast.notnull93: +// CHECK-LL-NEXT: %vtable94 = load i8** bitcast (%class.test1_D* @test1_d to i8**) +// CHECK-LL-NEXT: %vbase.offset.ptr95 = getelementptr i8* %vtable94, i64 -24 +// CHECK-LL-NEXT: %56 = bitcast i8* %vbase.offset.ptr95 to i64* +// CHECK-LL-NEXT: %vbase.offset96 = load i64* %56 +// CHECK-LL-NEXT: %add.ptr97 = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 %vbase.offset96 +// CHECK-LL-NEXT: %57 = bitcast i8* %add.ptr97 to %class.test1_A* +// CHECK-LL-NEXT: br label %cast.end99 +// CHECK-LL: cast.null98: +// CHECK-LL-NEXT: br label %cast.end99 +// CHECK-LL: cast.end99: +// CHECK-LL-NEXT: %58 = phi %class.test1_A* [ %57, %cast.notnull93 ], [ null, %cast.null98 ] +// CHECK-LL-NEXT: store %class.test1_A* %58, %class.test1_A** %ap +// CHECK-LL-NEXT: %tmp100 = load %class.test1_A** %ap +// CHECK-LL-NEXT: br i1 false, label %cast.null106, label %cast.notnull101 +// CHECK-LL: cast.notnull101: +// CHECK-LL-NEXT: %vtable102 = load i8** bitcast (%class.test1_D* @test1_d to i8**) +// CHECK-LL-NEXT: %vbase.offset.ptr103 = getelementptr i8* %vtable102, i64 -24 +// CHECK-LL-NEXT: %59 = bitcast i8* %vbase.offset.ptr103 to i64* +// CHECK-LL-NEXT: %vbase.offset104 = load i64* %59 +// CHECK-LL-NEXT: %add.ptr105 = getelementptr i8* getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0), i64 %vbase.offset104 +// CHECK-LL-NEXT: %60 = bitcast i8* %add.ptr105 to %class.test1_A* +// CHECK-LL-NEXT: br label %cast.end107 +// CHECK-LL: cast.null106: +// CHECK-LL-NEXT: br label %cast.end107 +// CHECK-LL: cast.end107: +// CHECK-LL-NEXT: %61 = phi %class.test1_A* [ %60, %cast.notnull101 ], [ null, %cast.null106 ] +// CHECK-LL-NEXT: %cmp108 = icmp eq %class.test1_A* %tmp100, %61 +// CHECK-LL-NEXT: br i1 %cmp108, label %if.then109, label %if.else111 +// CHECK-LL: if.then109: +// CHECK-LL-NEXT: %call110 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 12) +// CHECK-LL-NEXT: br label %if.end113 +// CHECK-LL: if.else111: +// CHECK-LL-NEXT: %call112 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 12) +// CHECK-LL-NEXT: br label %if.end113 +// CHECK-LL: if.end113: +// CHECK-LL-NEXT: br i1 false, label %cast.null116, label %cast.notnull115 +// CHECK-LL: cast.notnull115: +// CHECK-LL-NEXT: br label %cast.end117 +// CHECK-LL: cast.null116: +// CHECK-LL-NEXT: br label %cast.end117 +// CHECK-LL: cast.end117: +// CHECK-LL-NEXT: %62 = phi %class.test1_E* [ bitcast (%class.test1_F* @test1_f to %class.test1_E*), %cast.notnull115 ], [ null, %cast.null116 ] +// CHECK-LL-NEXT: store %class.test1_E* %62, %class.test1_E** %ep +// CHECK-LL-NEXT: %tmp118 = load %class.test1_E** %ep +// CHECK-LL-NEXT: br i1 false, label %cast.null120, label %cast.notnull119 +// CHECK-LL: cast.notnull119: +// CHECK-LL-NEXT: br label %cast.end121 +// CHECK-LL: cast.null120: +// CHECK-LL-NEXT: br label %cast.end121 +// CHECK-LL: cast.end121: +// CHECK-LL-NEXT: %63 = phi %class.test1_E* [ bitcast (%class.test1_F* @test1_f to %class.test1_E*), %cast.notnull119 ], [ null, %cast.null120 ] +// CHECK-LL-NEXT: %cmp122 = icmp eq %class.test1_E* %tmp118, %63 +// CHECK-LL-NEXT: br i1 %cmp122, label %if.then123, label %if.else125 +// CHECK-LL: if.then123: +// CHECK-LL-NEXT: %call124 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 13) +// CHECK-LL-NEXT: br label %if.end127 +// CHECK-LL: if.else125: +// CHECK-LL-NEXT: %call126 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 13) +// CHECK-LL-NEXT: br label %if.end127 +// CHECK-LL: if.end127: +// CHECK-LL-NEXT: %tmp129 = load %class.test1_A** %ap +// CHECK-LL-NEXT: %64 = icmp ne %class.test1_A* %tmp129, null +// CHECK-LL-NEXT: br i1 %64, label %65, label %70 +// CHECK-LL: ; <label>:65 +// CHECK-LL-NEXT: %66 = bitcast %class.test1_A* %tmp129 to i64** +// CHECK-LL-NEXT: %vtable130 = load i64** %66 +// CHECK-LL-NEXT: %67 = getelementptr inbounds i64* %vtable130, i64 -2 +// CHECK-LL-NEXT: %"offset to top" = load i64* %67 +// CHECK-LL-NEXT: %68 = bitcast %class.test1_A* %tmp129 to i8* +// CHECK-LL-NEXT: %69 = getelementptr inbounds i8* %68, i64 %"offset to top" +// CHECK-LL-NEXT: br label %71 +// CHECK-LL: ; <label>:70 +// CHECK-LL-NEXT: br label %71 +// CHECK-LL: ; <label>:71 +// CHECK-LL-NEXT: %72 = phi i8* [ %69, %65 ], [ null, %70 ] +// CHECK-LL-NEXT: store i8* %72, i8** %vp +// CHECK-LL-NEXT: %tmp131 = load i8** %vp +// CHECK-LL-NEXT: %cmp132 = icmp eq i8* %tmp131, getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0) +// CHECK-LL-NEXT: br i1 %cmp132, label %if.then133, label %if.else135 +// CHECK-LL: if.then133: +// CHECK-LL-NEXT: %call134 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 14) +// CHECK-LL-NEXT: br label %if.end137 +// CHECK-LL: if.else135: +// CHECK-LL-NEXT: %call136 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 14) +// CHECK-LL-NEXT: br label %if.end137 +// CHECK-LL: if.end137: +// CHECK-LL-NEXT: %tmp139 = load %class.test1_A** %ap +// CHECK-LL-NEXT: %73 = icmp ne %class.test1_A* %tmp139, null +// CHECK-LL-NEXT: br i1 %73, label %74, label %79 +// CHECK-LL: ; <label>:74 +// CHECK-LL-NEXT: %75 = bitcast %class.test1_A* %tmp139 to i64** +// CHECK-LL-NEXT: %vtable140 = load i64** %75 +// CHECK-LL-NEXT: %76 = getelementptr inbounds i64* %vtable140, i64 -2 +// CHECK-LL-NEXT: %"offset to top141" = load i64* %76 +// CHECK-LL-NEXT: %77 = bitcast %class.test1_A* %tmp139 to i8* +// CHECK-LL-NEXT: %78 = getelementptr inbounds i8* %77, i64 %"offset to top141" +// CHECK-LL-NEXT: br label %80 +// CHECK-LL: ; <label>:79 +// CHECK-LL-NEXT: br label %80 +// CHECK-LL: ; <label>:80 +// CHECK-LL-NEXT: %81 = phi i8* [ %78, %74 ], [ null, %79 ] +// CHECK-LL-NEXT: store i8* %81, i8** %cvp +// CHECK-LL-NEXT: %tmp142 = load i8** %cvp +// CHECK-LL-NEXT: %cmp143 = icmp eq i8* %tmp142, getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0) +// CHECK-LL-NEXT: br i1 %cmp143, label %if.then144, label %if.else146 +// CHECK-LL: if.then144: +// CHECK-LL-NEXT: %call145 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 15) +// CHECK-LL-NEXT: br label %if.end148 +// CHECK-LL: if.else146: +// CHECK-LL-NEXT: %call147 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str1, i32 0, i32 0), i32 15) +// CHECK-LL-NEXT: br label %if.end148 +// CHECK-LL: if.end148: +// CHECK-LL-NEXT: ret void diff --git a/test/CodeGenCXX/empty-union.cpp b/test/CodeGenCXX/empty-union.cpp new file mode 100644 index 000000000000..fdd97415a203 --- /dev/null +++ b/test/CodeGenCXX/empty-union.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc -emit-llvm -o - %s + +union sigval { }; + +union sigval sigev_value; + +int main() +{ + return sizeof(sigev_value); +} diff --git a/test/CodeGenCXX/explicit-instantiation.cpp b/test/CodeGenCXX/explicit-instantiation.cpp index 8a9e65c4e2e3..b33ba85cf660 100644 --- a/test/CodeGenCXX/explicit-instantiation.cpp +++ b/test/CodeGenCXX/explicit-instantiation.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -emit-llvm -triple i686-pc-linue-gnu -o %t %s && +// RUN: clang-cc -emit-llvm -triple i686-pc-linux-gnu -o %t %s // RUN: grep "define i32 @_ZNK4plusIillEclERKiRKl" %t | count 1 template<typename T, typename U, typename Result> diff --git a/test/CodeGenCXX/extern-c.cpp b/test/CodeGenCXX/extern-c.cpp index 635329323354..3af8f3adb54f 100644 --- a/test/CodeGenCXX/extern-c.cpp +++ b/test/CodeGenCXX/extern-c.cpp @@ -1,10 +1,10 @@ -// RUN: clang-cc -emit-llvm %s -o %t && +// RUN: clang-cc -emit-llvm %s -o %t namespace foo { -// RUN: not grep "@a = global i32" %t && +// RUN: not grep "@a = global i32" %t extern "C" int a; -// RUN: not grep "@_ZN3foo1bE = global i32" %t && +// RUN: not grep "@_ZN3foo1bE = global i32" %t extern int b; // RUN: grep "@_ZN3foo1cE = global i32" %t | count 1 diff --git a/test/CodeGenCXX/global-array-destruction.cpp b/test/CodeGenCXX/global-array-destruction.cpp new file mode 100644 index 000000000000..ebea9c156e27 --- /dev/null +++ b/test/CodeGenCXX/global-array-destruction.cpp @@ -0,0 +1,33 @@ +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s + +extern "C" int printf(...); + +int count; + +struct S { + S() : iS(++count) { printf("S::S(%d)\n", iS); } + ~S() { printf("S::~S(%d)\n", iS); } + int iS; +}; + + +S arr[2][1]; +S s1; +S arr1[3]; +static S sarr[4]; + +int main () {} +S arr2[2]; +static S sarr1[4]; +S s2; +S arr3[3]; + +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit +// CHECK-LP64: call ___cxa_atexit diff --git a/test/CodeGenCXX/implicit-instantiation-1.cpp b/test/CodeGenCXX/implicit-instantiation-1.cpp index f6c6114d20c3..cc86ef4cb502 100644 --- a/test/CodeGenCXX/implicit-instantiation-1.cpp +++ b/test/CodeGenCXX/implicit-instantiation-1.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -emit-llvm %s -o %t && +// RUN: clang-cc -emit-llvm %s -o %t template<typename T> struct X { @@ -11,18 +11,17 @@ struct X { }; void foo(X<int> &xi, X<float> *xfp, int i, float f) { - // RUN: grep "linkonce_odr.*_ZN1XIiE1fEi" %t | count 1 && + // RUN: grep "linkonce_odr.*_ZN1XIiE1fEi" %t | count 1 xi.f(i); - // RUN: grep "linkonce_odr.*_ZN1XIiE1gEi" %t | count 1 && + // RUN: grep "linkonce_odr.*_ZN1XIiE1gEi" %t | count 1 xi.g(f); - // RUN: grep "linkonce_odr.*_ZN1XIfE1fEf" %t | count 1 && + // RUN: grep "linkonce_odr.*_ZN1XIfE1fEf" %t | count 1 xfp->f(f); - // RUN: grep "linkonce_odr.*_ZN1XIfE1hEf" %t | count 0 && + // RUN: grep "linkonce_odr.*_ZN1XIfE1hEf" %t | count 0 - // RUN: true } diff --git a/test/CodeGenCXX/init-incomplete-type.cpp b/test/CodeGenCXX/init-incomplete-type.cpp new file mode 100644 index 000000000000..402b86ea8cb4 --- /dev/null +++ b/test/CodeGenCXX/init-incomplete-type.cpp @@ -0,0 +1,12 @@ +// RUN: clang-cc %s -emit-llvm-only -verify +// PR5489 + +template<typename E> +struct Bar { + int x_; +}; + +static struct Bar<int> bar[1] = { + { 0 } +}; + diff --git a/test/CodeGenCXX/instantiate-init-list.cpp b/test/CodeGenCXX/instantiate-init-list.cpp new file mode 100644 index 000000000000..7d5458af1f55 --- /dev/null +++ b/test/CodeGenCXX/instantiate-init-list.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc %s -emit-llvm-only -verify + +struct F { + void (*x)(); +}; +void G(); +template<class T> class A { + A(); +}; +template<class T> A<T>::A() { + static F f = { G }; +} +A<int> a; diff --git a/test/CodeGenCXX/mangle-subst.cpp b/test/CodeGenCXX/mangle-subst.cpp index 46a21b62b515..a940f4f447b6 100644 --- a/test/CodeGenCXX/mangle-subst.cpp +++ b/test/CodeGenCXX/mangle-subst.cpp @@ -59,3 +59,11 @@ template void ft3<int>(S1<int>, S1<char>); // CHECK: @_Z1fPKcS0_ void f(const char*, const char*) {} +namespace NS { + class C; +} + +namespace NS { + // CHECK: @_ZN2NS1fERNS_1CE + void f(C&) { } +} diff --git a/test/CodeGenCXX/mangle-system-header.cpp b/test/CodeGenCXX/mangle-system-header.cpp new file mode 100644 index 000000000000..8c642bd07533 --- /dev/null +++ b/test/CodeGenCXX/mangle-system-header.cpp @@ -0,0 +1,7 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s + +// PR5420 + +# 1 "fake_system_header.h" 1 3 4 +// CHECK: define void @_ZdlPvS_( +void operator delete (void*, void*) {} diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index 2ffbae71da01..03e405ecba1d 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -221,3 +221,9 @@ struct S7 { // CHECK: @"_ZN2S73$_0C1Ev" S7::S7() {} +// PR5063 +template<typename T> typename __enable_if<(__is_scalar<T>::__value), void>::__type ft8() { } +// CHECK: @_Z3ft8IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv +template void ft8<int>(); +// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv +template void ft8<void*>(); diff --git a/test/CodeGenCXX/member-expressions.cpp b/test/CodeGenCXX/member-expressions.cpp new file mode 100644 index 000000000000..f90b80733905 --- /dev/null +++ b/test/CodeGenCXX/member-expressions.cpp @@ -0,0 +1,19 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s + +// PR5392 +namespace PR5392 { +struct A +{ + static int a; +}; + +A a1; +void f() +{ + // CHECK: store i32 10, i32* @_ZN6PR53921A1aE + a1.a = 10; + // CHECK: store i32 20, i32* @_ZN6PR53921A1aE + A().a = 20; +} + +} diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index a7c21133d051..7792560e067b 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -30,8 +30,8 @@ void f() { // CHECK: volatile store i64 0, i64* getelementptr inbounds (%0* @vpa, i32 0, i32 1) vpa = 0; - // CHECK: store i64 %0, i64* getelementptr inbounds (%0* @pc, i32 0, i32 0) - // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 %1, 16 + // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pc, i32 0, i32 0) + // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 16 // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pc, i32 0, i32 1) pc = pa; } @@ -46,7 +46,7 @@ void f2() { // CHECK: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 // CHECK: store i64 1, i64* [[pa3ptr]] // CHECK: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa2adj]] + // CHECK: store i64 0, i64* [[pa3adj]] void (A::*pa3)() = &A::vf; } diff --git a/test/CodeGenCXX/member-functions.cpp b/test/CodeGenCXX/member-functions.cpp index 29629d5bf824..0dfaedff931c 100644 --- a/test/CodeGenCXX/member-functions.cpp +++ b/test/CodeGenCXX/member-functions.cpp @@ -1,43 +1,43 @@ -// RUN: clang-cc -emit-llvm %s -triple x86_64-apple-darwin9 -o %t && +// RUN: clang-cc -emit-llvm %s -triple x86_64-apple-darwin9 -o %t struct C { void f(); void g(int, ...); }; -// RUN: grep "define void @_ZN1C1fEv" %t | count 1 && +// RUN: grep "define void @_ZN1C1fEv" %t | count 1 void C::f() { } void test1() { C c; -// RUN: grep "call void @_ZN1C1fEv" %t | count 1 && +// RUN: grep "call void @_ZN1C1fEv" %t | count 1 c.f(); -// RUN: grep "call void (.struct.C\*, i32, ...)\* @_ZN1C1gEiz" %t | count 1 && +// RUN: grep "call void (.struct.C\*, i32, ...)\* @_ZN1C1gEiz" %t | count 1 c.g(1, 2, 3); } struct S { - // RUN: grep "define linkonce_odr void @_ZN1SC1Ev" %t && + // RUN: grep "define linkonce_odr void @_ZN1SC1Ev" %t inline S() { } - // RUN: grep "define linkonce_odr void @_ZN1SC1Ev" %t && + // RUN: grep "define linkonce_odr void @_ZN1SC1Ev" %t inline ~S() { } - // RUN: grep "define linkonce_odr void @_ZN1S9f_inline1Ev" %t && + // RUN: grep "define linkonce_odr void @_ZN1S9f_inline1Ev" %t void f_inline1() { } - // RUN: grep "define linkonce_odr void @_ZN1S9f_inline2Ev" %t && + // RUN: grep "define linkonce_odr void @_ZN1S9f_inline2Ev" %t inline void f_inline2() { } - // RUN: grep "define linkonce_odr void @_ZN1S1gEv" %t && + // RUN: grep "define linkonce_odr void @_ZN1S1gEv" %t static void g() { } static void f(); }; -// RUN: grep "define void @_ZN1S1fEv" %t && +// RUN: grep "define void @_ZN1S1fEv" %t void S::f() { } diff --git a/test/CodeGenCXX/member-init-struct.cpp b/test/CodeGenCXX/member-init-struct.cpp new file mode 100644 index 000000000000..9c0c3919794e --- /dev/null +++ b/test/CodeGenCXX/member-init-struct.cpp @@ -0,0 +1,18 @@ +// RUN: clang-cc %s -emit-llvm-only -verify + +struct A {int a;}; +struct B {float a;}; +struct C { + union { + A a; + B b[10]; + }; + _Complex float c; + int d[10]; + void (C::*e)(); + C() : a(), c(), d(), e() {} + C(A x) : a(x) {} + C(void (C::*x)(), int y) : b(), c(y), e(x) {} +}; +A x; +C a, b(x), c(0, 2); diff --git a/test/CodeGenCXX/member-init-union.cpp b/test/CodeGenCXX/member-init-union.cpp new file mode 100644 index 000000000000..334d5fd1f1c4 --- /dev/null +++ b/test/CodeGenCXX/member-init-union.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc %s -emit-llvm-only -verify + +union x { + int a; + float b; + x(float y) : b(y) {} + x(int y) : a(y) {} +}; +x a(1), b(1.0f); + diff --git a/test/CodeGenCXX/member-pointers-zero-init.cpp b/test/CodeGenCXX/member-pointers-zero-init.cpp index e7b0fdafba6a..caf31bd0621a 100644 --- a/test/CodeGenCXX/member-pointers-zero-init.cpp +++ b/test/CodeGenCXX/member-pointers-zero-init.cpp @@ -1,30 +1,30 @@ -// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 && +// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 struct A { int i; }; -// RUN: grep "@a = global i64 -1" %t && +// RUN: grep "@a = global i64 -1" %t int A::* a; -// RUN: grep "@aa = global \[2 x i64\] \[i64 -1, i64 -1\]" %t && +// RUN: grep "@aa = global \[2 x i64\] \[i64 -1, i64 -1\]" %t int A::* aa[2]; -// RUN: grep "@aaa = global \[2 x \[2 x i64\]\] \[\[2 x i64\] \[i64 -1, i64 -1\], \[2 x i64\] \[i64 -1, i64 -1\]\]" %t && +// RUN: grep "@aaa = global \[2 x \[2 x i64\]\] \[\[2 x i64\] \[i64 -1, i64 -1\], \[2 x i64\] \[i64 -1, i64 -1\]\]" %t int A::* aaa[2][2]; -// RUN: grep "@b = global i64 -1" %t && +// RUN: grep "@b = global i64 -1" %t int A::* b = 0; void f() { - // RUN: grep "%.* = icmp ne i64 %.*, -1" %t | count 2 && + // RUN: grep "%.* = icmp ne i64 %.*, -1" %t | count 2 if (a) { } if (a != 0) { } - // RUN: grep "%.* = icmp ne i64 -1, %.*" %t | count 1 && + // RUN: grep "%.* = icmp ne i64 -1, %.*" %t | count 1 if (0 != a) { } - // RUN: grep "%.* = icmp eq i64 %.*, -1" %t | count 1 && + // RUN: grep "%.* = icmp eq i64 %.*, -1" %t | count 1 if (a == 0) { } // RUN: grep "%.* = icmp eq i64 -1, %.*" %t | count 1 diff --git a/test/CodeGenCXX/new-operator-phi.cpp b/test/CodeGenCXX/new-operator-phi.cpp new file mode 100644 index 000000000000..a5eed28ccf95 --- /dev/null +++ b/test/CodeGenCXX/new-operator-phi.cpp @@ -0,0 +1,11 @@ +// RUN: clang-cc -emit-llvm-only -verify %s +// PR5454 +#include <stddef.h> + +class X {static void * operator new(size_t size) throw(); X(int); }; +int a(), b(); +void b(int x) +{ + new X(x ? a() : b()); +} + diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp index c6cee1845670..3f191de23bcf 100644 --- a/test/CodeGenCXX/new.cpp +++ b/test/CodeGenCXX/new.cpp @@ -1,11 +1,12 @@ // RUN: clang-cc %s -emit-llvm -o - | FileCheck %s +#include <stddef.h> void t1() { int* a = new int; } // Placement. -void* operator new(unsigned long, void*) throw(); +void* operator new(size_t, void*) throw(); void t2(int* a) { int* b = new (a) int; diff --git a/test/CodeGenCXX/ptr-to-member-function.cpp b/test/CodeGenCXX/ptr-to-member-function.cpp index 15019081c062..52190b937377 100644 --- a/test/CodeGenCXX/ptr-to-member-function.cpp +++ b/test/CodeGenCXX/ptr-to-member-function.cpp @@ -1,8 +1,7 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s && -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s +// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s // 13.3.3.2 Ranking implicit conversion sequences extern "C" int printf(...); diff --git a/test/CodeGenCXX/reinterpret-cast.cpp b/test/CodeGenCXX/reinterpret-cast.cpp index ae3ab2f8b0d7..58a980d5288c 100644 --- a/test/CodeGenCXX/reinterpret-cast.cpp +++ b/test/CodeGenCXX/reinterpret-cast.cpp @@ -9,4 +9,9 @@ unsigned long f2() { unsigned long f3(void *p) { return reinterpret_cast<unsigned long>(p); +} + +void f4(int*&); +void f5(void*& u) { + f4(reinterpret_cast<int*&>(u)); }
\ No newline at end of file diff --git a/test/CodeGenCXX/rtti.cpp b/test/CodeGenCXX/rtti.cpp new file mode 100644 index 000000000000..a1ff1ff68729 --- /dev/null +++ b/test/CodeGenCXX/rtti.cpp @@ -0,0 +1,207 @@ +// RUN: clang-cc -I%S -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t.s +// RUN: FileCheck --input-file=%t.s %s + +// RUN: clang-cc -I%S -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll +// RUN: FileCheck -check-prefix LL --input-file=%t.ll %s + +#include <typeinfo> + +class test1_B1 { + virtual void foo() { } +}; +class test1_B2 : public test1_B1 { + virtual void foo() { } +}; +class test1_B3 : public test1_B2, public test1_B1 { + virtual void foo() { } +}; +class test1_B4 : virtual public test1_B3 { + virtual void foo() { } +}; +class test1_B5 : virtual test1_B3, test1_B4 { + virtual void foo() { } +}; +class test1_B6 { + virtual void foo() { } +}; +class test1_B7 : public test1_B6, public test1_B5 { + virtual void foo() { } +}; +class test1_D : public test1_B7 { + virtual void foo() { } +} d1; + +// CHECK: __ZTSPVi: +// CHECK-NEXT: .asciz "PVi" + +// CHECK: __ZTIPVi: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv119__pointer_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTSPVi +// CHECK-NEXT: .long 2 +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .quad __ZTIi + +// CHECK: .globl __ZTS7test3_A +// CHECK-NEXT: .weak_definition __ZTS7test3_A +// CHECK: __ZTS7test3_A: +// CHECK-NEXT: .asciz "7test3_A" + +// CHECK: __ZTIM7test3_Ai: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTSM7test3_Ai +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .quad __ZTIi +// CHECK-NEXT: .quad __ZTI7test3_A + +// CHECK: __ZTIM7test3_Ii: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTSM7test3_Ii +// CHECK-NEXT: .long 16 +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .quad __ZTIi +// CHECK-NEXT: .quad __ZTI7test3_I + +// CHECK: .private_extern __ZTIFvvE +// CHECK: .globl __ZTIFvvE +// CHECK: .weak_definition __ZTIFvvE +// CHECK: __ZTIFvvE: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__function_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTSFvvE + +// CHECK: __ZTIM7test3_AFvvE: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTSM7test3_AFvvE +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .space 4 +// CHECK-NEXT: .quad __ZTIFvvE +// CHECK-NEXT: .quad __ZTI7test3_A + + + +// CHECK:__ZTI7test1_D: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__si_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS7test1_D +// CHECK-NEXT: .quad __ZTI8test1_B7 + +// CHECK:__ZTI8test1_B7: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B7 +// CHECK-NEXT: .long 3 +// CHECK-NEXT: .long 2 +// CHECK-NEXT: .quad __ZTI8test1_B6 +// CHECK-NEXT: .quad 2 +// CHECK-NEXT: .quad __ZTI8test1_B5 +// CHECK-NEXT: .quad 2050 + +// CHECK:__ZTI8test1_B5: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B5 +// CHECK-NEXT: .long 3 +// CHECK-NEXT: .long 2 +// CHECK-NEXT: .quad __ZTI8test1_B3 +// CHECK-NEXT: .quad 18446744073709545473 +// CHECK-NEXT: .quad __ZTI8test1_B4 +// CHECK-NEXT: .space 8 + +// CHECK:__ZTI8test1_B4: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B4 +// CHECK-NEXT: .long 1 +// CHECK-NEXT: .long 1 +// CHECK-NEXT: .quad __ZTI8test1_B3 +// CHECK-NEXT: .quad 18446744073709545475 + +// CHECK:__ZTI8test1_B6: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv117__class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B6 + +// CHECK:__ZTI8test1_B3: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv121__vmi_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B3 +// CHECK-NEXT: .long 1 +// CHECK-NEXT: .long 2 +// CHECK-NEXT: .quad __ZTI8test1_B2 +// CHECK-NEXT: .quad 2 +// CHECK-NEXT: .quad __ZTI8test1_B1 +// CHECK-NEXT: .quad 2050 + +// CHECK:__ZTS8test1_B1: +// CHECK-NEXT: .asciz "8test1_B1" + +// CHECK:__ZTI8test1_B1: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv117__class_type_infoE) + 16 +// CHECK-NEXT:. quad __ZTS8test1_B1 + +// CHECK:__ZTS8test1_B2: +// CHECK-NEXT: .asciz "8test1_B2" + +// CHECK:__ZTI8test1_B2: +// CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__si_class_type_infoE) + 16 +// CHECK-NEXT: .quad __ZTS8test1_B2 +// CHECK-NEXT: .quad __ZTI8test1_B1 + + +class NP { }; +void test2_1(); +void test2_2(test1_D *dp) { + test1_D &d = *dp; + if (typeid(d) == typeid(test1_D)) + test2_1(); + if (typeid(NP) == typeid(test1_D)) + test2_1(); + if (typeid(((*(dp)))) == typeid(test1_D)) + test2_1(); + if (typeid(int) == typeid(float)) + test2_1(); + if (typeid(int*) == typeid(const int *)) + test2_1(); +} + +// CHECK-LL:define void @_Z7test2_2P7test1_D(%class.test1_B7* %dp) nounwind { +// CHECK-LL: %tmp1 = load %class.test1_B7** %d +// CHECK-LL-NEXT: %0 = bitcast %class.test1_B7* %tmp1 to %"class.std::type_info"*** +// CHECK-LL-NEXT: %vtable = load %"class.std::type_info"*** %0 +// CHECK-LL-NEXT: %1 = getelementptr inbounds %"class.std::type_info"** %vtable, i64 -1 +// CHECK-LL-NEXT: %2 = load %"class.std::type_info"** %1 +// CHECK-LL-NEXT: %call = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %2, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*)) + +// CHECK-LL: %call2 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (%0* @_ZTI2NP to %"class.std::type_info"*), %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*)) + +// CHECK-LL: %3 = bitcast %class.test1_B7* %tmp5 to %"class.std::type_info"*** +// CHECK-LL-NEXT: %4 = icmp ne %"class.std::type_info"*** %3, null +// CHECK-LL-NEXT: br i1 %4, label %6, label %5 +// CHECK-LL: ; <label>:5 +// CHECK-LL-NEXT: call void @__cxa_bad_typeid() +// CHECK-LL-NEXT: unreachable +// CHECK-LL: ; <label>:6 +// CHECK-LL-NEXT: %vtable6 = load %"class.std::type_info"*** %3 +// CHECK-LL-NEXT: %7 = getelementptr inbounds %"class.std::type_info"** %vtable6, i64 -1 +// CHECK-LL-NEXT: %8 = load %"class.std::type_info"** %7 +// CHECK-LL-NEXT: %call7 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %8, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*)) + +// CHECK-LL: %call10 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIf to %"class.std::type_info"*)) + +// CHECK-LL: %call13 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIPi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIPKi to %"class.std::type_info"*)) + +class test3_A { }; +class test3_I; +int (test3_A::*pmd); +int (test3_I::*i_pmd); +void (test3_A::*pmf)(); +int test3() { + if (typeid(volatile int *) == typeid(int *)) + return 1; + if (typeid(pmd) == typeid(i_pmd)) + return 1; + if (typeid(pmd) == typeid(pmf)) + return 1; + return 0; + enum a { }; + if (typeid(int[5]) == typeid(enum a)) + return 0; +} + +bool test4(std::type_info* __pointee) { + return *__pointee == typeid (void); +} diff --git a/test/CodeGenCXX/static-init-1.cpp b/test/CodeGenCXX/static-init-1.cpp new file mode 100644 index 000000000000..2c452022c525 --- /dev/null +++ b/test/CodeGenCXX/static-init-1.cpp @@ -0,0 +1,23 @@ +// RUN: clang-cc -triple=x86_64-apple-darwin9 -emit-llvm %s -o %t +// RUN: grep "call i32 @_Z5func1i" %t | count 3 + +extern "C" int printf(...); + +static int count; + +int func2(int c) { return printf("loading the func2(%d)\n", c); }; +int func1(int c) { return printf("loading the func1(%d)\n", c); } + +static int loader_1 = func1(++count); + +int loader_2 = func2(++count); + +static int loader_3 = func1(++count); + + +int main() {} + +int loader_4 = func2(++count); +static int loader_5 = func1(++count); +int loader_6 = func2(++count); + diff --git a/test/CodeGenCXX/static-init-2.cpp b/test/CodeGenCXX/static-init-2.cpp new file mode 100644 index 000000000000..e229dd4aa734 --- /dev/null +++ b/test/CodeGenCXX/static-init-2.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -emit-llvm-only -verify %s + +// Make sure we don't crash generating y; its value is constant, but the +// initializer has side effects, so EmitConstantExpr should fail. +int x(); +int y = x() && 0; diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp index 44dd14284107..55877b2a71a9 100644 --- a/test/CodeGenCXX/static-init.cpp +++ b/test/CodeGenCXX/static-init.cpp @@ -1,5 +1,5 @@ -// RUN: clang-cc -triple=x86_64-apple-darwin9 -emit-llvm %s -o %t && -// RUN: grep "call void @_ZN1AC1Ev" %t | count 1 && +// RUN: clang-cc -triple=x86_64-apple-darwin9 -emit-llvm %s -o %t +// RUN: grep "call void @_ZN1AC1Ev" %t | count 1 // RUN: grep "call i32 @__cxa_atexit(void (i8\*)\* bitcast (void (%.truct.A\*)\* @_ZN1AD1Ev to void (i8\*)\*), i8\* getelementptr inbounds (%.truct.A\* @_ZZ1fvE1a, i32 0, i32 0), i8\* bitcast (i8\*\* @__dso_handle to i8\*))" %t | count 1 struct A { diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp index e9ed0f7690bc..e55027460f0c 100644 --- a/test/CodeGenCXX/temporaries.cpp +++ b/test/CodeGenCXX/temporaries.cpp @@ -115,3 +115,90 @@ void f7() { // CHECK: call void @_ZN1GD1Ev a(G()); } + +namespace PR5077 { + +struct A { + A(); + ~A(); + int f(); +}; + +void f(); +int g(const A&); + +struct B { + int a1; + int a2; + B(); + ~B(); +}; + +B::B() + // CHECK: call void @_ZN6PR50771AC1Ev + // CHECK: call i32 @_ZN6PR50771A1fEv + // CHECK: call void @_ZN6PR50771AD1Ev + : a1(A().f()) + // CHECK: call void @_ZN6PR50771AC1Ev + // CHECK: call i32 @_ZN6PR50771gERKNS_1AE + // CHECK: call void @_ZN6PR50771AD1Ev + , a2(g(A())) +{ + // CHECK: call void @_ZN6PR50771fEv + f(); +} + +struct C { + C(); + + const B& b; +}; + +C::C() + // CHECK: call void @_ZN6PR50771BC1Ev + : b(B()) { + // CHECK: call void @_ZN6PR50771fEv + f(); + + // CHECK: call void @_ZN6PR50771BD1Ev +} +} + +A f8() { + // CHECK: call void @_ZN1AC1Ev + // CHECK-NOT: call void @_ZN1AD1Ev + return A(); + // CHECK: ret void +} + +struct H { + H(); + ~H(); + H(const H&); +}; + +void f9(H h) { + // CHECK: call void @_ZN1HC1Ev + // CHECK: call void @_Z2f91H + // CHECK: call void @_ZN1HD1Ev + f9(H()); + + // CHECK: call void @_ZN1HC1ERKS_ + // CHECK: call void @_Z2f91H + // CHECK: call void @_ZN1HD1Ev + f9(h); +} + +void f10(const H&); + +void f11(H h) { + // CHECK: call void @_ZN1HC1Ev + // CHECK: call void @_Z3f10RK1H + // CHECK: call void @_ZN1HD1Ev + f10(H()); + + // CHECK: call void @_Z3f10RK1H + // CHECK-NOT: call void @_ZN1HD1Ev + // CHECK: ret void + f10(h); +}
\ No newline at end of file diff --git a/test/CodeGenCXX/trivial-constructor-init.cpp b/test/CodeGenCXX/trivial-constructor-init.cpp index 183b31a801e3..90d6e655d8d8 100644 --- a/test/CodeGenCXX/trivial-constructor-init.cpp +++ b/test/CodeGenCXX/trivial-constructor-init.cpp @@ -1,6 +1,5 @@ -// RUN: clang-cc -S %s -o %t-64.s && -// RUN: clang-cc -S %s -o %t-32.s && -// RUN: true +// RUN: clang-cc -S %s -o %t-64.s +// RUN: clang-cc -S %s -o %t-32.s extern "C" int printf(...); diff --git a/test/CodeGenCXX/typeinfo b/test/CodeGenCXX/typeinfo new file mode 100644 index 000000000000..7af23cf12f0d --- /dev/null +++ b/test/CodeGenCXX/typeinfo @@ -0,0 +1,16 @@ +namespace std { + class type_info { + public: + virtual ~type_info(); + const char* name() const { return __name; } + bool operator==(const type_info& __arg) const { + return __name == __arg.__name; + } + + bool operator!=(const type_info& __arg) const { + return !operator==(__arg); + } + protected: + const char *__name; + }; +} diff --git a/test/CodeGenCXX/vararg-conversion-ctor.cpp b/test/CodeGenCXX/vararg-conversion-ctor.cpp new file mode 100644 index 000000000000..1306abf4a63d --- /dev/null +++ b/test/CodeGenCXX/vararg-conversion-ctor.cpp @@ -0,0 +1,23 @@ +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll +// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s + +extern "C" int printf(...); + +struct A { + A(...) { + printf("A::A(...)\n"); + } +}; + +A a(1.34); + +A b = 2.34; + +int main() +{ + A c[3]; +} + +// CHECK-LPLL64: call void (%struct.A*, ...) +// CHECK-LPLL64: call void (%struct.A*, ...) +// CHECK-LPLL64: call void (%struct.A*, ...) diff --git a/test/CodeGenCXX/virt-dtor-gen.cpp b/test/CodeGenCXX/virt-dtor-gen.cpp new file mode 100644 index 000000000000..704d735c776e --- /dev/null +++ b/test/CodeGenCXX/virt-dtor-gen.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc -o - -emit-llvm %s | FileCheck %s +// PR5483 + +// Make sure we generate all three forms of the destructor when it is virtual. +class Foo { + virtual ~Foo(); +}; +Foo::~Foo() {} + +// CHECK: define void @_ZN3FooD0Ev diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp index 193a96ddd589..b453ed55df3e 100644 --- a/test/CodeGenCXX/virt.cpp +++ b/test/CodeGenCXX/virt.cpp @@ -1,14 +1,8 @@ -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s && -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -O0 -S %s -o %t-32.s && -// RUN: FileCheck -check-prefix LP32 -input-file=%t-32.s %s && +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -O3 -S %s -o %t-O3-64.s && -// RUN: FileCheck -check-prefix LPOPT64 --input-file=%t-O3-64.s %s && -// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -O3 -S %s -o %t-O3-32.s && -// RUN: FileCheck -check-prefix LPOPT32 -input-file=%t-O3-32.s %s && - -// RUN: true +// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll +// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s struct B { virtual void bar1(); @@ -56,8 +50,8 @@ void test2() { j = sz; // FIXME: These should result in a frontend constant a la fold, no run time // initializer - // CHECK-LPOPT32: movl $4, __ZZ5test2vE2sz - // CHECK-LPOPT64: movl $8, __ZZ5test2vE2sz(%rip) + // CHECK-LPLL64: define void @_Z5test2v() + // CHECK-LPLL64: = getelementptr inbounds %class.F* %f, i32 0, i32 1 } static_assert(sizeof(F) == sizeof(void*)*4, "invalid vbase size"); @@ -85,10 +79,6 @@ int main() { ap->b = 2; } -// CHECK-LP32: main: -// CHECK-LP32: movl $1, 8(%eax) -// CHECK-LP32: movl $2, 4(%eax) - // CHECK-LP64: main: // CHECK-LP64: movl $1, 12(%rax) // CHECK-LP64: movl $2, 8(%rax) @@ -114,56 +104,14 @@ void test12_foo() { test12_pa->test12_A::foo(); } -// CHECK-LPOPT32:__Z10test12_foov: -// CHECK-LPOPT32: movl _test12_pa, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pb, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pd, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pa, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *4(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pb, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *4(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pd, %eax -// CHECK-LPOPT32-NEXT: movl (%eax), %ecx -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call *4(%ecx) -// CHECK-LPOPT32-NEXT: movl _test12_pa, %eax -// CHECK-LPOPT32-NEXT: movl %eax, (%esp) -// CHECK-LPOPT32-NEXT: call L__ZN8test12_A3fooEv$stub - -// CHECK-LPOPT64:__Z10test12_foov: -// CHECK-LPOPT64: movq _test12_pa(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pb(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pd(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pa(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *8(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pb(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *8(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pd(%rip), %rdi -// CHECK-LPOPT64-NEXT: movq (%rdi), %rax -// CHECK-LPOPT64-NEXT: call *8(%rax) -// CHECK-LPOPT64-NEXT: movq _test12_pa(%rip), %rdi -// CHECK-LPOPT64-NEXT: call __ZN8test12_A3fooEv +// CHECK-LPLL64:define void @_Z10test12_foov() nounwind { +// CHECK-LPLL64: call void %2(%class.test14* %tmp) +// CHECK-LPLL64: call void %5(%class.test14* %tmp1) +// CHECK-LPLL64: call void %8(%class.test14* %tmp3) +// CHECK-LPLL64: call void %11(%class.test14* %tmp5) +// CHECK-LPLL64: call void %14(%class.test14* %tmp7) +// CHECK-LPLL64: call void %17(%class.test14* %tmp9) +// CHECK-LPLL64: call void @_ZN8test12_A3fooEv(%class.test14* %tmp11) struct test6_B2 { virtual void funcB2(); char b[1000]; }; @@ -172,7 +120,6 @@ struct test6_B1 : virtual test6_B2 { virtual void funcB1(); }; struct test6_D : test6_B2, virtual test6_B1 { }; -// CHECK-LP32: .zerofill __DATA, __common, _d6, 2012, 4 // CHECK-LP64: .zerofill __DATA, __common, _d6, 2024, 4 struct test7_B2 { virtual void funcB2(); }; @@ -181,7 +128,6 @@ struct test7_B1 : virtual test7_B2 { virtual void funcB1(); }; struct test7_D : test7_B2, virtual test7_B1 { }; -// CHECK-LP32: .zerofill __DATA, __common, _d7, 8, 3 // CHECK-LP64: .zerofill __DATA, __common, _d7, 16, 3 @@ -193,20 +139,6 @@ struct test3_D : virtual test3_B1 { virtual void funcD() { } }; -// CHECK-LP32:__ZTV7test3_D: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI7test3_D -// CHECK-LP32-NEXT: .long __ZN8test3_B36funcB3Ev -// CHECK-LP32-NEXT: .long __ZN8test3_B26funcB2Ev -// CHECK-LP32-NEXT: .long __ZN8test3_B16funcB1Ev -// CHECK-LP32-NEXT: .long __ZN7test3_D5funcDEv - // CHECK-LP64:__ZTV7test3_D: // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .space 8 @@ -224,22 +156,6 @@ struct test3_D : virtual test3_B1 { struct test4_D : virtual B, virtual C { }; -// CHECK-LP32:__ZTV7test4_D: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI7test4_D -// CHECK-LP32-NEXT: .long __ZN1C4bee1Ev -// CHECK-LP32-NEXT: .long __ZN1C4bee2Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI7test4_D -// CHECK-LP32-NEXT: .long __ZN1B4bar1Ev -// CHECK-LP32-NEXT: .long __ZN1B4bar2Ev - // CHECK-LP64:__ZTV7test4_D: // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad 8 @@ -277,58 +193,6 @@ struct test5_D : virtual test5_B1, virtual test5_B21, virtual test5_B31 { virtual void funcD() { } }; -// CHECK-LP32:__ZTV7test5_D: -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI7test5_D -// CHECK-LP32-NEXT: .long __ZN8test5_B36funcB3Ev -// CHECK-LP32-NEXT: .long __ZN8test5_B26funcB2Ev -// CHECK-LP32-NEXT: .long __ZN8test5_B16funcB1Ev -// CHECK-LP32-NEXT: .long __ZN7test5_D5funcDEv -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI7test5_D -// CHECK-LP32-NEXT: .long __ZN9test5_B237funcB23Ev -// CHECK-LP32-NEXT: .long __ZN9test5_B227funcB22Ev -// CHECK-LP32-NEXT: .long __ZN9test5_B217funcB21Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long __ZTI7test5_D -// CHECK-LP32-NEXT: .long __ZN9test5_B337funcB33Ev -// CHECK-LP32-NEXT: .long __ZN9test5_B327funcB32Ev -// CHECK-LP32-NEXT: .long __ZN9test5_B317funcB31Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI7test5_D -// CHECK-LP32-NEXT: .long __ZN4B2328funcB232Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967280 -// CHECK-LP32-NEXT: .long __ZTI7test5_D -// CHECK-LP32-NEXT: .long __ZN4B2318funcB231Ev - // CHECK-LP64:__ZTV7test5_D: // CHECK-LP64-NEXT: .quad 32 // CHECK-LP64-NEXT: .quad 24 @@ -407,33 +271,6 @@ struct test8_B3 { class test8_D : test8_B1, test8_B2, test8_B3 { }; -// CHECK-LP32:__ZTV7test8_D: -// CHECK-LP32-NEXT: .long 24 -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN8test8_B19ftest8_B1Ev -// CHECK-LP32-NEXT: .long 20 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN9test8_B2a10ftest8_B2aEv -// CHECK-LP32-NEXT: .long __ZN8test8_B29ftest8_B2Ev -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN9test8_B2b10ftest8_B2bEv -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN8test8_B39ftest8_B3Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967280 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN10test8_B2aa11ftest8_B2aaEv -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967272 -// CHECK-LP32-NEXT: .long __ZTI7test8_D -// CHECK-LP32-NEXT: .long __ZN10test8_B2ab11ftest8_B2abEv - // CHECK-LP64:__ZTV7test8_D: // CHECK-LP64-NEXT: .quad 48 // CHECK-LP64-NEXT: .quad 32 @@ -461,6 +298,49 @@ class test8_D : test8_B1, test8_B2, test8_B3 { // CHECK-LP64-NEXT: .quad __ZTI7test8_D // CHECK-LP64-NEXT: .quad __ZN10test8_B2ab11ftest8_B2abEv +// CHECK-LP64:__ZTC7test8_D8_8test8_B2: +// CHECK-LP64-NEXT: .quad 40 +// CHECK-LP64-NEXT: .quad 24 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI8test8_B2 +// CHECK-LP64-NEXT: .quad __ZN9test8_B2a10ftest8_B2aEv +// CHECK-LP64-NEXT: .quad __ZN8test8_B29ftest8_B2Ev +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad 18446744073709551592 +// CHECK-LP64-NEXT: .quad __ZTI8test8_B2 +// CHECK-LP64-NEXT: .quad __ZN10test8_B2aa11ftest8_B2aaEv +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad 18446744073709551576 +// CHECK-LP64-NEXT: .quad __ZTI8test8_B2 +// CHECK-LP64-NEXT: .quad __ZN10test8_B2ab11ftest8_B2abEv + +// CHECK-LP64:__ZTC7test8_D8_9test8_B2a: +// CHECK-LP64-NEXT: .quad 40 +// CHECK-LP64-NEXT: .quad 24 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI9test8_B2a +// CHECK-LP64-NEXT: .quad __ZN9test8_B2a10ftest8_B2aEv +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad 18446744073709551592 +// CHECK-LP64-NEXT: .quad __ZTI9test8_B2a +// CHECK-LP64-NEXT: .quad __ZN10test8_B2aa11ftest8_B2aaEv +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad 18446744073709551576 +// CHECK-LP64-NEXT: .quad __ZTI9test8_B2a +// CHECK-LP64-NEXT: .quad __ZN10test8_B2ab11ftest8_B2abEv + +// CHECK-LP64:__ZTT7test8_D: +// CHECK-LP64-NEXT: .quad (__ZTV7test8_D) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC7test8_D8_8test8_B2) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC7test8_D8_9test8_B2a) + 32 +// CHECK-LP64-NEXT .quad (__ZTC7test8_D8_9test8_B2a) + 64 +// CHECK-LP64-NEXT .quad (__ZTC7test8_D8_9test8_B2a) + 96 +// CHECK-LP64-NEXT .quad (__ZTC7test8_D8_8test8_B2) + 72 +// CHECK-LP64-NEXT .quad (__ZTC7test8_D8_8test8_B2) + 104 +// CHECK-LP64-NEXT .quad (__ZTV7test8_D) + 72 +// CHECK-LP64: .quad (__ZTV7test8_D) + 160 +// CHECK-LP64: .quad (__ZTV7test8_D) + 192 + struct test9_B3 { virtual void funcB3(); int i; }; struct test9_B2 : virtual test9_B3 { virtual void funcB2(); int i; }; @@ -554,77 +434,6 @@ struct test9_D : virtual test9_B1, virtual test9_B21, virtual test9_B31 { // CHECK-LP64-NEXT: .quad __ZTI7test9_D // CHECK-LP64-NEXT: .quad __ZN10test9_B2318funcB231Ev -// CHECK-LP32: __ZTV7test9_D: -// CHECK-LP32-NEXT: .long 84 -// CHECK-LP32-NEXT: .long 76 -// CHECK-LP32-NEXT: .long 68 -// CHECK-LP32-NEXT: .long 60 -// CHECK-LP32-NEXT: .long 52 -// CHECK-LP32-NEXT: .long 44 -// CHECK-LP32-NEXT: .long 36 -// CHECK-LP32-NEXT: .long 28 -// CHECK-LP32-NEXT: .long 20 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN7test9_D5funcDEv -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN8test9_B16funcB1Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN8test9_B26funcB2Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN8test9_B36funcB3Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967268 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B217funcB21Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967260 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B227funcB22Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967252 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B237funcB23Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 32 -// CHECK-LP32-NEXT: .long 24 -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967244 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B317funcB31Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967236 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B327funcB32Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967228 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN9test9_B337funcB33Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967220 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN10test9_B2328funcB232Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967212 -// CHECK-LP32-NEXT: .long __ZTI7test9_D -// CHECK-LP32-NEXT: .long __ZN10test9_B2318funcB231Ev struct test10_O { int i; }; @@ -673,26 +482,6 @@ class test10_D : test10_B1, test10_B2 { // CHECK-LP64-NEXT: .quad 18446744073709551576 // CHECK-LP64-NEXT: .quad __ZTI8test10_D -// CHECK-LP32: __ZTV8test10_D: -// CHECK-LP32-NEXT: .long 20 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI8test10_D -// CHECK-LP32-NEXT: .long __ZN9test10_B110ftest10_B1Ev -// CHECK-LP32-NEXT: .long 16 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI8test10_D -// CHECK-LP32-NEXT: .long __ZN10test10_B2a11ftest10_B2aEv -// CHECK-LP32-NEXT: .long __ZN9test10_B210ftest10_B2Ev -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI8test10_D -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .long __ZTI8test10_D struct test11_B { virtual void B1() { } @@ -706,16 +495,6 @@ struct test11_D : test11_B { virtual void D2() { } }; -// CHECK-LP32:__ZTV8test11_D: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI8test11_D -// CHECK-LP32-NEXT: .long __ZN8test11_B2B1Ev -// CHECK-LP32-NEXT: .long __ZN8test11_D1DEv -// CHECK-LP32-NEXT: .long __ZN8test11_B2B2Ev -// CHECK-LP32-NEXT: .long __ZN8test11_D2D1Ev -// CHECK-LP32-NEXT: .long __ZN8test11_D2D2Ev - - // CHECK-LP64:__ZTV8test11_D: // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad __ZTI8test11_D @@ -803,47 +582,6 @@ struct test13_D : test13_NV1, virtual test13_B2 { // CHECK-LP64-NEXT: .quad __ZN8test13_B2DcEv // CHECK-LP64-NEXT: .quad __ZTv0_n64_N9test13_B22B2Ev -// CHECK-LP32:__ZTV8test13_D: -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI8test13_D -// CHECK-LP32-NEXT: .long __ZN8test13_D6fooNV1Ev -// CHECK-LP32-NEXT: .long __ZN8test13_D1DEv -// CHECK-LP32-NEXT: .long __ZN8test13_D2D1Ev -// CHECK-LP32-NEXT: .long __ZN8test13_D2DbEv -// CHECK-LP32-NEXT: .long __ZN8test13_D2DdEv -// CHECK-LP32-NEXT: .long __ZN8test13_D2D2Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .long 4294967292 -// CHECK-LP32-NEXT: .long __ZTI8test13_D -// CHECK-LP32-NEXT: .long __ZN9test13_B23B2aEv -// CHECK-LP32-NEXT: .long __ZN9test13_B22B2Ev -// CHECK-LP32-NEXT: .long __ZTv0_n24_N8test13_D1DEv -// CHECK-LP32-NEXT: .long __ZN9test13_B22DaEv -// CHECK-LP32-NEXT: .long __ZTv0_n32_N8test13_D2DdEv -// CHECK-LP32-NEXT: .long __ZN9test13_B23B2bEv -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI8test13_D -// CHECK-LP32-NEXT: .long __ZN8test13_B2B1Ev -// CHECK-LP32-NEXT: .long __ZTv0_n16_N8test13_D1DEv -// CHECK-LP32-NEXT: .long __ZTv0_n20_N9test13_B22DaEv -// CHECK-LP32-NEXT: .long __ZTv0_n24_N8test13_D2DbEv -// CHECK-LP32-NEXT: .long __ZN8test13_B2DcEv -// CHECK-LP32-NEXT: .long __ZTv0_n32_N9test13_B22B2Ev - class test14 { public: @@ -907,31 +645,6 @@ struct test15_D : test15_NV1, virtual test15_B2 { // CHECK-LP64-NEXT: .quad __ZTcv0_n32_v0_n24_N9test15_B24foo2Ev // CHECK-LP64-NEXT: .quad __ZN8test15_B4foo3Ev -// CHECK-LP32:__ZTV8test15_D: -// CHECK-LP32-NEXT: .long 20 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI8test15_D -// CHECK-LP32-NEXT: .long __ZN10test15_NV16fooNV1Ev -// CHECK-LP32-NEXT: .long __ZN8test15_D4foo1Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long __ZTI8test15_D -// CHECK-LP32-NEXT: .long __ZN10test15_NV16fooNV1Ev -// CHECK-LP32-NEXT: .long __ZTcv0_n20_v0_n12_N8test15_D4foo1Ev -// CHECK-LP32-NEXT: .long __ZN9test15_B24foo2Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .long __ZTI8test15_D -// CHECK-LP32-NEXT: .long __ZTcv0_n12_v0_n16_N8test15_D4foo1Ev -// CHECK-LP32-NEXT: .long __ZTcv0_n16_v0_n12_N9test15_B24foo2Ev -// CHECK-LP32-NEXT: .long __ZN8test15_B4foo3Ev - struct test16_NV1 { virtual void fooNV1() { } @@ -995,7 +708,7 @@ void test16_D::bar() { } // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .space 8 // CHECK-LP64: .quad 18446744073709551600 -// CHECK-LP64: .quad 18446744073709551584 +// CHECK-LP64-NEXT: .quad 18446744073709551584 // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad 18446744073709551584 @@ -1012,80 +725,60 @@ void test16_D::bar() { } // CHECK-LP64: .quad __ZN10test16_NV27foo_NV2Ev // CHECK-LP64-NEXT: .quad __ZN10test16_NV28foo_NV2bEv -// CHECK-LP32: __ZTV8test16_D: -// CHECK-LP32-NEXT: .long 20 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI8test16_D -// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev -// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev -// CHECK-LP32-NEXT: .long __ZN8test16_D3barEv -// CHECK-LP32-NEXT: .long __ZN8test16_D4foo1Ev -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 12 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long __ZTI8test16_D -// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev -// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev -// CHECK-LP32-NEXT: .long __ZTcv0_n24_v0_n12_N8test16_D4foo1Ev -// CHECK-LP32-NEXT: .long __ZN9test16_B24foo2Ev -// CHECK-LP32-NEXT: .long __ZN9test16_B26foo_B2Ev -// CHECK-LP32-NEXT .long 8 -// CHECK-LP32-NEXT .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32: .long 4294967284 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967276 -// CHECK-LP32-NEXT: .long __ZTI8test16_D -// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev -// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev -// CHECK-LP32-NEXT: .long __ZTcv0_n20_v0_n16_N8test16_D4foo1Ev -// CHECK-LP32-NEXT: .long __ZTcv0_n24_v0_n12_N9test16_B24foo2Ev -// CHECK-LP32-NEXT: .long __ZN8test16_B4foo3Ev -// CHECK-LP32-NEXT: .long __ZN8test16_B5foo_BEv -// CHECK-LP32-NEXT: .long 4294967268 -// CHECK-LP32-NEXT: .long __ZTI8test16_D -// CHECK-LP32-NEXT .long __ZTcvn8_n20_v8_n16_N8test16_D4foo1Ev -// CHECK-LP32: .long __ZN10test16_NV27foo_NV2Ev -// CHECK-LP32-NEXT: .long __ZN10test16_NV28foo_NV2bEv - // FIXME: This is the wrong thunk, but until these issues are fixed, better // than nothing. -// CHECK-LPOPT64: __ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev: -// CHECK-LPOPT64-NEXT:Leh_func_begin -// CHECK-LPOPT64-NEXT: subq $8, %rsp -// CHECK-LPOPT64-NEXT:Llabel -// CHECK-LPOPT64-NEXT: movq -16(%rdi), %rax -// CHECK-LPOPT64-NEXT: movq -72(%rax), %rax -// CHECK-LPOPT64-NEXT: leaq -16(%rax,%rdi), %rdi -// FIXME: We want a tail call here -// CHECK-LPOPT64-NEXT: call __ZTch0_v16_n32_N8test16_D4foo1Ev -// CHECK-LPOPT64-NEXT: addq $8, %rsp -// CHECK-LPOPT64-NEXT: ret +// CHECK-LPLL64:define weak %class.test8_D* @_ZTcvn16_n72_v16_n32_N8test16_D4foo1Ev(%class.test8_D*) { +// CHECK-LPLL64:entry: +// CHECK-LPLL64: %retval = alloca %class.test8_D* +// CHECK-LPLL64: %.addr = alloca %class.test8_D* +// CHECK-LPLL64: store %class.test8_D* %0, %class.test8_D** %.addr +// CHECK-LPLL64: %this = load %class.test8_D** %.addr +// CHECK-LPLL64: %1 = bitcast %class.test8_D* %this to i8* +// CHECK-LPLL64: %2 = getelementptr inbounds i8* %1, i64 -16 +// CHECK-LPLL64: %3 = bitcast i8* %2 to %class.test8_D* +// CHECK-LPLL64: %4 = bitcast %class.test8_D* %3 to i8* +// CHECK-LPLL64: %5 = bitcast %class.test8_D* %3 to i64** +// CHECK-LPLL64: %vtable = load i64** %5 +// CHECK-LPLL64: %6 = getelementptr inbounds i64* %vtable, i64 -9 +// CHECK-LPLL64: %7 = load i64* %6 +// CHECK-LPLL64: %8 = getelementptr i8* %4, i64 %7 +// CHECK-LPLL64: %9 = bitcast i8* %8 to %class.test8_D* +// CHECK-LPLL64: %call = call %class.test8_D* @_ZTch0_v16_n32_N8test16_D4foo1Ev(%class.test8_D* %9) +// CHECK-LPLL64: store %class.test8_D* %call, %class.test8_D** %retval +// CHECK-LPLL64: %10 = load %class.test8_D** %retval +// CHECK-LPLL64: ret %class.test8_D* %10 +// CHECK-LPLL64:} -// CHECK-LPOPT64: __ZTch0_v16_n32_N8test16_D4foo1Ev: -// CHECK-LPOPT64-NEXT:Leh_func_begin -// CHECK-LPOPT64-NEXT: subq $8, %rsp -// CHECK-LPOPT64-NEXT:Llabel -// CHECK-LPOPT64-NEXT: call __ZN8test16_D4foo1Ev -// CHECK-LPOPT64-NEXT: testq %rax, %rax -// CHECK-LPOPT64-NEXT: je LBB102_2 -// CHECK-LPOPT64-NEXT: movq 16(%rax), %rcx -// CHECK-LPOPT64-NEXT: movq -32(%rcx), %rcx -// CHECK-LPOPT64-NEXT: leaq 16(%rcx,%rax), %rax -// CHECK-LPOPT64-NEXT: addq $8, %rsp -// CHECK-LPOPT64-NEXT: ret -// CHECK-LPOPT64-NEXT:LBB102_2: -// CHECK-LPOPT64-NEXT: addq $8, %rsp -// CHECK-LPOPT64-NEXT: ret +// CHECK-LPLL64:define weak %class.test8_D* @_ZTch0_v16_n32_N8test16_D4foo1Ev(%class.test8_D*) { +// CHECK-LPLL64:entry: +// CHECK-LPLL64: %retval = alloca %class.test8_D* +// CHECK-LPLL64: %.addr = alloca %class.test8_D* +// CHECK-LPLL64: store %class.test8_D* %0, %class.test8_D** %.addr +// CHECK-LPLL64: %this = load %class.test8_D** %.addr +// CHECK-LPLL64: %call = call %class.test8_D* @_ZN8test16_D4foo1Ev(%class.test8_D* %this) +// CHECK-LPLL64: %1 = icmp ne %class.test8_D* %call, null +// CHECK-LPLL64: br i1 %1, label %2, label %12 +// CHECK-LPLL64:; <label>:2 +// CHECK-LPLL64: %3 = bitcast %class.test8_D* %call to i8* +// CHECK-LPLL64: %4 = getelementptr inbounds i8* %3, i64 16 +// CHECK-LPLL64: %5 = bitcast i8* %4 to %class.test8_D* +// CHECK-LPLL64: %6 = bitcast %class.test8_D* %5 to i8* +// CHECK-LPLL64: %7 = bitcast %class.test8_D* %5 to i64** +// CHECK-LPLL64: %vtable = load i64** %7 +// CHECK-LPLL64: %8 = getelementptr inbounds i64* %vtable, i64 -4 +// CHECK-LPLL64: %9 = load i64* %8 +// CHECK-LPLL64: %10 = getelementptr i8* %6, i64 %9 +// CHECK-LPLL64: %11 = bitcast i8* %10 to %class.test8_D* +// CHECK-LPLL64: br label %13 +// CHECK-LPLL64:; <label>:12 +// CHECK-LPLL64: br label %13 +// CHECK-LPLL64:; <label>:13 +// CHECK-LPLL64: %14 = phi %class.test8_D* [ %11, %2 ], [ %call, %12 ] +// CHECK-LPLL64: store %class.test8_D* %14, %class.test8_D** %retval +// CHECK-LPLL64: %15 = load %class.test8_D** %retval +// CHECK-LPLL64: ret %class.test8_D* %15 +// CHECK-LPLL64:} class test17_B1 { @@ -1220,16 +913,27 @@ struct test19_D : virtual test19_B4 { // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad __ZTI8test19_D -// CHECK-LP64-NEXT .quad __ZN9test19_B13fB1Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B26foB1B2Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B36foB1B3Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B46foB1B4Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B23fB2Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B36foB2B3Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B46foB2B4Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B33fB3Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B46foB3B4Ev -// CHECK-LP64-NEXT .quad __ZN9test19_B43fB4Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B13fB1Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B26foB1B2Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B36foB1B3Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B46foB1B4Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B23fB2Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B36foB2B3Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B46foB2B4Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B33fB3Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B46foB3B4Ev +// CHECK-LP64-NEXT: .quad __ZN9test19_B43fB4Ev + +// CHECK-LP64: __ZTT8test19_D: +// CHECK-LP64-NEXT: .quad (__ZTV8test19_D) + 144 +// CHECK-LP64-NEXT: .quad (__ZTV8test19_D) + 144 +// CHECK-LP64-NEXT .quad (__ZTV8test19_D) + 144 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B4) + 136 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B3) + 104 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B3) + 104 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B4) + 136 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B2) + 88 +// CHECK-LP64-NEXT .quad (__ZTC8test19_D0_9test19_B1) + 24 class test20_V { @@ -1243,7 +947,7 @@ class test20_B : virtual test20_V { class test20_B1 : virtual test20_V1 { }; class test20_D : public test20_B, public test20_B1 { -} d; +}; // CHECK-LP64: __ZTV8test20_D: // CHECK-LP64-NEXT: .quad 8 @@ -1258,6 +962,82 @@ class test20_D : public test20_B, public test20_B1 { // CHECK-LP64-NEXT: .quad __ZTI8test20_D // CHECK-LP64-NEXT: .quad __ZN9test20_V14foo2Ev +// CHECK-LP64: __ZTC8test20_D0_8test20_B: +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI8test20_B +// CHECK-LP64-NEXT: .quad __ZN8test20_V4foo1Ev + +// CHECK-LP64: __ZTC8test20_D8_9test20_B1: +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI9test20_B1 +// CHECK-LP64-NEXT: .quad __ZN9test20_V14foo2Ev + +// CHECK-LP64: __ZTT8test20_D: +// CHECK-LP64-NEXT: .quad (__ZTV8test20_D) + 40 +// CHECK-LP64-NEXT: .quad (__ZTC8test20_D0_8test20_B) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test20_D0_8test20_B) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test20_D8_9test20_B1) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test20_D8_9test20_B1) + 32 +// CHECK-LP64-NEXT .quad (__ZTV8test20_D) + 40 +// CHECK-LP64-NEXT .quad (__ZTV8test20_D) + 80 +// CHECK-LP64-NEXT .quad (__ZTV8test20_D) + 80 + + +class test21_V { + virtual void foo() { } +}; +class test21_V1 { + virtual void foo() { } +}; +class test21_B : virtual test21_V { +}; +class test21_B1 : virtual test21_V1 { +}; +class test21_D : public test21_B, public test21_B1 { + void foo() { } +}; + +// CHECK-LP64: __ZTV8test21_D: +// CHECK-LP64-NEXT: .quad 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI8test21_D +// CHECK-LP64-NEXT: .quad __ZN8test21_D3fooEv +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad 18446744073709551608 +// CHECK-LP64-NEXT: .quad 18446744073709551608 +// CHECK-LP64-NEXT: .quad __ZTI8test21_D +// CHECK-LP64-NEXT: .quad __ZTv0_n24_N8test21_D3fooEv + +// CHECK-LP64: __ZTC8test21_D0_8test21_B: +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI8test21_B +// CHECK-LP64-NEXT: .quad __ZN8test21_V3fooEv + +// CHECK-LP64: __ZTC8test21_D8_9test21_B1: +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .space 8 +// CHECK-LP64-NEXT: .quad __ZTI9test21_B1 +// CHECK-LP64-NEXT: .quad __ZN9test21_V13fooEv + +// CHECK-LP64: __ZTT8test21_D: +// CHECK-LP64-NEXT: .quad (__ZTV8test21_D) + 40 +// CHECK-LP64-NEXT: .quad (__ZTC8test21_D0_8test21_B) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test21_D0_8test21_B) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test21_D8_9test21_B1) + 32 +// CHECK-LP64-NEXT: .quad (__ZTC8test21_D8_9test21_B1) + 32 +// CHECK-LP64-NEXT .quad (__ZTV8test21_D) + 40 +// CHECK-LP64-NEXT .quad (__ZTV8test21_D) + 80 +// CHECK-LP64-NEXT .quad (__ZTV8test21_D) + 80 + // CHECK-LP64: __ZTV1B: @@ -1266,12 +1046,6 @@ class test20_D : public test20_B, public test20_B1 { // CHECK-LP64-NEXT: .quad __ZN1B4bar1Ev // CHECK-LP64-NEXT: .quad __ZN1B4bar2Ev -// CHECK-LP32: __ZTV1B: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI1B -// CHECK-LP32-NEXT: .long __ZN1B4bar1Ev -// CHECK-LP32-NEXT: .long __ZN1B4bar2Ev - // CHECK-LP64: __ZTV1A: // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad __ZTI1A @@ -1284,39 +1058,6 @@ class test20_D : public test20_B, public test20_B1 { // CHECK-LP64-NEXT: .quad __ZN1C4bee1Ev // CHECK-LP64-NEXT: .quad __ZN1C4bee2Ev -// CHECK-LP32: __ZTV1A: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI1A -// CHECK-LP32-NEXT: .long __ZN1B4bar1Ev -// CHECK-LP32-NEXT: .long __ZN1B4bar2Ev -// CHECK-LP32-NEXT: .long __ZN1A4foo1Ev -// CHECK-LP32-NEXT: .long __ZN1A4foo2Ev -// CHECK-LP32-NEXT: .long 4294967284 -// CHECK-LP32-NEXT: .long __ZTI1A -// CHECK-LP32-NEXT: .long __ZN1C4bee1Ev -// CHECK-LP32-NEXT: .long __ZN1C4bee2Ev - -// CHECK-LP32:__ZTV1F: -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 8 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long __ZTI1F -// CHECK-LP32-NEXT: .long __ZN1D3booEv -// CHECK-LP32-NEXT: .long __ZN1F3fooEv -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .space 4 -// CHECK-LP32-NEXT: .long 4294967288 -// CHECK-LP32-NEXT: .long __ZTI1F -// CHECK-LP32-NEXT: .long __ZN2D13barEv -// CHECK-LP32-NEXT: .long __ZN2D14bar2Ev -// CHECK-LP32-NEXT: .long __ZN2D14bar3Ev -// CHECK-LP32-NEXT: .long __ZN2D14bar4Ev -// CHECK-LP32-NEXT: .long __ZN2D14bar5Ev - // CHECK-LP64: __ZTV1F: // CHECK-LP64-NEXT: .space 8 // CHECK-LP64-NEXT: .quad 16 @@ -1338,6 +1079,8 @@ class test20_D : public test20_B, public test20_B1 { // CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev // CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev +test21_D d21; +test20_D d20; test19_D d19; test18_D d18; test17_D d17; diff --git a/test/CodeGenCXX/virtual-operator-call.cpp b/test/CodeGenCXX/virtual-operator-call.cpp new file mode 100644 index 000000000000..018052bb472c --- /dev/null +++ b/test/CodeGenCXX/virtual-operator-call.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +struct A { + virtual int operator-() = 0; +}; + +void f(A *a) { + // CHECK: call i32 % + -*a; +} diff --git a/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp b/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp new file mode 100644 index 000000000000..3d99a0216073 --- /dev/null +++ b/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s + +struct A { + virtual ~A(); +}; + +void f(A *a) { + // CHECK: call void % + a->~A(); +} diff --git a/test/CodeGenCXX/x86_64-arguments.cpp b/test/CodeGenCXX/x86_64-arguments.cpp index 426c867a7b6b..6b5e7a7a1d2c 100644 --- a/test/CodeGenCXX/x86_64-arguments.cpp +++ b/test/CodeGenCXX/x86_64-arguments.cpp @@ -1,10 +1,9 @@ -// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm -o %t %s && +// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm -o %t %s struct A { ~A(); }; -// RUN: grep 'define void @_Z2f11A(.struct.A\* .a)' %t && +// RUN: grep 'define void @_Z2f11A(.struct.A\* .a)' %t void f1(A a) { } -// RUN: grep 'define void @_Z2f2v(.struct.A\* noalias sret .agg.result)' %t && +// RUN: grep 'define void @_Z2f2v(.struct.A\* noalias sret .agg.result)' %t A f2() { return A(); } -// RUN: true |
