• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
2 // <rdar://problem/11043589>
3 
4 struct Length {
LengthLength5   Length(double v) {
6     m_floatValue = static_cast<float>(v);
7   }
8 
operator ==Length9   bool operator==(const Length& o) const {
10     return getFloatValue() == o.getFloatValue();
11   }
operator !=Length12   bool operator!=(const Length& o) const { return !(*this == o); }
13 private:
getFloatValueLength14   float getFloatValue() const {
15     return m_floatValue;
16   }
17   float m_floatValue;
18 };
19 
20 
21 struct Foo {
22   static Length inchLength(double inch);
getPageSizeFromNameFoo23   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
31 // CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length, %struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 4
32 
bar(Length & b)33 bool bar(Length &b) {
34   Foo f;
35   return f.getPageSizeFromName(b);
36 }
37