// RUN: %clang_cc1 -no-opaque-pointers %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -no-opaque-pointers %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
// Instantiation order varies on different C++ dialects (IE, between C++98 and C++11).
// CHECK-DAG: @_ZN7PR100011xE ={{.*}} global
// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
// Negative checks go under prefix "CHECK2" to avoid interference with CHECK and CHECK-DAG.
// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE ={{.*}} constant
// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
// CHECK2-NOT: _ZTVN5test31SIiEE
// CHECK2-NOT: _ZTSN5test31SIiEE
// CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* {{[^,]*}} %this) unnamed_addr
// CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
// CHECK-LABEL: define available_externally void @_ZN5test21CIiE6zedbarEd(
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi1EEE()
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi2EEE()
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi3EEE()
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi1EEE()
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi2EEE()
// CHECK-LABEL: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi3EEE()
// CHECK: declare void @_ZN7PR106662h1ENS_1SILi1EEE()
// CHECK: declare void @_ZN7PR106662h1ENS_1SILi2EEE()
// CHECK: declare void @_ZN7PR106662h1ENS_1SILi3EEE()
// CHECK: declare void @_ZN7PR106662h2ENS_1SILi1EEE()
// CHECK: declare void @_ZN7PR106662h2ENS_1SILi2EEE()
// CHECK: declare void @_ZN7PR106662h2ENS_1SILi3EEE()
// Ensure that when instantiating initializers for static data members to
// complete their type in an unevaluated context, we *do* emit initializers with
// side-effects, but *don't* emit initializers and variables which are otherwise
// unused in the program.
// Ensure that definitions are emitted for all friend functions defined within
// class templates. Order of declaration is extremely important here. Different
// instantiations of the class happen at different points during the deferred
// method body parsing and afterward. Those different points of instantiation
// change the exact form the class template appears to have.