brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.2 KiB · 9394e6b Raw
133 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-STATIC-BL2// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BL3// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END | FileCheck %s --check-prefix=CHECK-STATIC-BE4// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BE5 6namespace std {7  typedef decltype(sizeof(int)) size_t;8 9  template <class _E>10  class initializer_list11  {12    const _E* __begin_;13#ifdef USE_END14    const _E* __end_;15#else16    size_t    __size_;17#endif18 19    constexpr initializer_list(const _E* __b, size_t __s)20      : __begin_(__b),21#ifdef USE_END22        __end_(__b + __s)23#else24        __size_(__s)25#endif26    {}27 28  public:29    typedef _E        value_type;30    typedef const _E& reference;31    typedef const _E& const_reference;32    typedef size_t    size_type;33 34    typedef const _E* iterator;35    typedef const _E* const_iterator;36 37#ifdef USE_END38    constexpr initializer_list() : __begin_(nullptr), __end_(nullptr) {}39 40    size_t    size()  const {return __end_ - __begin_;}41    const _E* begin() const {return __begin_;}42    const _E* end()   const {return __end_;}43#else44    constexpr initializer_list() : __begin_(nullptr), __size_(0) {}45 46    size_t    size()  const {return __size_;}47    const _E* begin() const {return __begin_;}48    const _E* end()   const {return __begin_ + __size_;}49#endif50  };51}52 53constexpr int a = 2, b = 4, c = 6;54std::initializer_list<std::initializer_list<int>> nested = {55  {1, a}, {3, b}, {5, c}56};57 58// CHECK-STATIC-BL: @_ZGR6nested0_ = internal constant [2 x i32] [i32 1, i32 2], align 459// CHECK-STATIC-BL: @_ZGR6nested1_ = internal constant [2 x i32] [i32 3, i32 4], align 460// CHECK-STATIC-BL: @_ZGR6nested2_ = internal constant [2 x i32] [i32 5, i32 6], align 461// CHECK-STATIC-BL: @_ZGR6nested_ = internal constant [3 x {{.*}}] [62// CHECK-STATIC-BL:   {{.*}} { ptr @_ZGR6nested0_, i64 2 },63// CHECK-STATIC-BL:   {{.*}} { ptr @_ZGR6nested1_, i64 2 },64// CHECK-STATIC-BL:   {{.*}} { ptr @_ZGR6nested2_, i64 2 }65// CHECK-STATIC-BL: ], align 866// CHECK-STATIC-BL: @nested ={{.*}} global {{.*}} { {{.*}} @_ZGR6nested_, i64 3 }, align 867 68// CHECK-DYNAMIC-BL: @nested ={{.*}} global69// CHECK-DYNAMIC-BL: @_ZGR6nested_ = internal global [3 x70// CHECK-DYNAMIC-BL: @_ZGR6nested0_ = internal global [2 x i32] zeroinitializer71// CHECK-DYNAMIC-BL: @_ZGR6nested1_ = internal global [2 x i32] zeroinitializer72// CHECK-DYNAMIC-BL: @_ZGR6nested2_ = internal global [2 x i32] zeroinitializer73// CHECK-DYNAMIC-BL: store i32 1, ptr @_ZGR6nested0_74// CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested0_, i64 1)75// CHECK-DYNAMIC-BL: store ptr @_ZGR6nested0_,76// CHECK-DYNAMIC-BL:       ptr @_ZGR6nested_, align 877// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds nuw ({{.*}}, ptr @_ZGR6nested_, i32 0, i32 1), align 878// CHECK-DYNAMIC-BL: store i32 3, ptr @_ZGR6nested1_79// CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1)80// CHECK-DYNAMIC-BL: store ptr @_ZGR6nested1_,81// CHECK-DYNAMIC-BL:       ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), align 882// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds nuw ({{.*}}, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i32 0, i32 1), align 883// CHECK-DYNAMIC-BL: store i32 5, ptr @_ZGR6nested2_84// CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested2_, i64 1)85// CHECK-DYNAMIC-BL: store ptr @_ZGR6nested2_,86// CHECK-DYNAMIC-BL:       ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2), align 887// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds nuw ({{.*}}, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2), i32 0, i32 1), align 888// CHECK-DYNAMIC-BL: store ptr @_ZGR6nested_,89// CHECK-DYNAMIC-BL:       ptr @nested, align 890// CHECK-DYNAMIC-BL: store i64 3, ptr getelementptr inbounds nuw ({{.*}}, ptr @nested, i32 0, i32 1), align 891 92// CHECK-STATIC-BE: @_ZGR6nested0_ = internal constant [2 x i32] [i32 1, i32 2], align 493// CHECK-STATIC-BE: @_ZGR6nested1_ = internal constant [2 x i32] [i32 3, i32 4], align 494// CHECK-STATIC-BE: @_ZGR6nested2_ = internal constant [2 x i32] [i32 5, i32 6], align 495// CHECK-STATIC-BE: @_ZGR6nested_ = internal constant [3 x {{.*}}] [96// CHECK-STATIC-BE:   {{.*}} { ptr @_ZGR6nested0_,97// CHECK-STATIC-BE:            ptr getelementptr (i8, ptr @_ZGR6nested0_, i64 8) }98// CHECK-STATIC-BE:   {{.*}} { ptr @_ZGR6nested1_,99// CHECK-STATIC-BE:            ptr getelementptr (i8, ptr @_ZGR6nested1_, i64 8) }100// CHECK-STATIC-BE:   {{.*}} { ptr @_ZGR6nested2_,101// CHECK-STATIC-BE:            ptr getelementptr (i8, ptr @_ZGR6nested2_, i64 8) }102// CHECK-STATIC-BE: ], align 8103// CHECK-STATIC-BE: @nested ={{.*}} global {{.*}} { ptr @_ZGR6nested_,104// CHECK-STATIC-BE:                           {{.*}} getelementptr (i8, ptr @_ZGR6nested_, i64 48) }105 106// CHECK-DYNAMIC-BE: @nested ={{.*}} global107// CHECK-DYNAMIC-BE: @_ZGR6nested_ = internal global [3 x108// CHECK-DYNAMIC-BE: @_ZGR6nested0_ = internal global [2 x i32] zeroinitializer109// CHECK-DYNAMIC-BE: @_ZGR6nested1_ = internal global [2 x i32] zeroinitializer110// CHECK-DYNAMIC-BE: @_ZGR6nested2_ = internal global [2 x i32] zeroinitializer111// CHECK-DYNAMIC-BE: store i32 1, ptr @_ZGR6nested0_112// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested0_, i64 1)113// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested0_,114// CHECK-DYNAMIC-BE:       ptr @_ZGR6nested_, align 8115// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested0_, i64 0, i64 2),116// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds nuw ({{.*}}, ptr @_ZGR6nested_, i32 0, i32 1), align 8117// CHECK-DYNAMIC-BE: store i32 3, ptr @_ZGR6nested1_118// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1)119// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested1_,120// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), align 8121// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested1_, i64 0, i64 2),122// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds nuw ({{.*}}, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i32 0, i32 1), align 8123// CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_124// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested2_, i64 1)125// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested2_,126// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2), align 8127// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested2_, i64 0, i64 2),128// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds nuw ({{.*}}, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2), i32 0, i32 1), align 8129// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested_,130// CHECK-DYNAMIC-BE:       ptr @nested, align 8131// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([3 x {{.*}}], ptr @_ZGR6nested_, i64 0, i64 3),132// CHECK-DYNAMIC-BE:       ptr getelementptr inbounds nuw ({{.*}}, ptr @nested, i32 0, i32 1), align 8133