Bill Wendling | f6af30f | 2012-03-16 21:45:12 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s |
| 2 | // <rdar://problem/11043589> |
| 3 | |
| 4 | struct Length { |
| 5 | Length(double v) { |
| 6 | m_floatValue = static_cast<float>(v); |
| 7 | } |
| 8 | |
| 9 | bool operator==(const Length& o) const { |
| 10 | return getFloatValue() == o.getFloatValue(); |
| 11 | } |
| 12 | bool operator!=(const Length& o) const { return !(*this == o); } |
| 13 | private: |
| 14 | float getFloatValue() const { |
| 15 | return m_floatValue; |
| 16 | } |
| 17 | float m_floatValue; |
| 18 | }; |
| 19 | |
| 20 | |
| 21 | struct Foo { |
| 22 | static Length inchLength(double inch); |
| 23 | static bool getPageSizeFromName(const Length &A) { |
| 24 | static const Length legalWidth = inchLength(8.5); |
| 25 | if (A != legalWidth) return true; |
| 26 | return false; |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | // CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4 |
Ulrich Weigand | 6e2cea6 | 2015-07-10 11:31:43 +0000 | [diff] [blame] | 31 | // CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length, %struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 4 |
Bill Wendling | f6af30f | 2012-03-16 21:45:12 +0000 | [diff] [blame] | 32 | |
| 33 | bool bar(Length &b) { |
| 34 | Foo f; |
| 35 | return f.getPageSizeFromName(b); |
| 36 | } |