From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- .../devirtualize-virtual-function-calls-final.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp (limited to 'clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp') diff --git a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp new file mode 100644 index 0000000..3de75ed --- /dev/null +++ b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s + +namespace Test1 { + struct A { + virtual int f() final; + }; + + // CHECK: define i32 @_ZN5Test11fEPNS_1AE + int f(A *a) { + // CHECK: call i32 @_ZN5Test11A1fEv + return a->f(); + } +} + +namespace Test2 { + struct A final { + virtual int f(); + }; + + // CHECK: define i32 @_ZN5Test21fEPNS_1AE + int f(A *a) { + // CHECK: call i32 @_ZN5Test21A1fEv + return a->f(); + } +} + +namespace Test3 { + struct A { + virtual int f(); + }; + + struct B final : A { }; + + // CHECK: define i32 @_ZN5Test31fEPNS_1BE + int f(B *b) { + // CHECK: call i32 @_ZN5Test31A1fEv + return b->f(); + } + + // CHECK: define i32 @_ZN5Test31fERNS_1BE + int f(B &b) { + // CHECK: call i32 @_ZN5Test31A1fEv + return b.f(); + } + + // CHECK: define i32 @_ZN5Test31fEPv + int f(void *v) { + // CHECK: call i32 @_ZN5Test31A1fEv + return static_cast(v)->f(); + } +} -- cgit v1.2.3