1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-unknown-unknown -fms-extensions | FileCheck %s
2 // rdar://17784718
3 
4 typedef struct _GUID
5 {
6     unsigned int  Data1;
7     unsigned short Data2;
8     unsigned short Data3;
9     unsigned char  Data4[ 8 ];
10 } GUID;
11 
12 
13 template < typename T, const GUID & T_iid = __uuidof(T)>
14 class UUIDTest
15 {
16 public:
17 	UUIDTest() { }
18 };
19 
20 struct __declspec(uuid("EAFA1952-66F8-438B-8FBA-AF1BBAE42191")) TestStruct
21 {
22 	int foo;
23 };
24 
25 struct __declspec(uuid("EAFA1952-66F8-438B-8FBA-AF1BBAE42191")) OtherStruct {};
26 
27 template <class T> void test_uuidofType(void *arg[sizeof(__uuidof(T))] = 0) {}
28 
29 template <class T> void test_uuidofExpr(void *arg[sizeof(__uuidof(typename T::member))] = 0) {}
30 
31 struct HasMember { typedef TestStruct member; };
32 
33 template<const GUID&> struct UUIDTestTwo { UUIDTestTwo(); };
34 
35 int main(int argc, const char * argv[])
36 {
37     UUIDTest<TestStruct> uuidof_test;
38     // Note that these variables have the same type, so the mangling of that
39     // type had better not mention TestStruct or OtherStruct!
40     UUIDTestTwo<__uuidof(TestStruct)> uuidof_test2;
41     UUIDTestTwo<__uuidof(OtherStruct)> uuidof_test3;
42     test_uuidofType<TestStruct>();
43     test_uuidofExpr<HasMember>();
44     return 0;
45 }
46 
47 // CHECK: define i32 @main
48 // CHECK: call void @_ZN8UUIDTestI10TestStructL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC1Ev
49 // CHECK: call void @_ZN11UUIDTestTwoIL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC1Ev
50 // CHECK: call void @_ZN11UUIDTestTwoIL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC1Ev
51 // CHECK: call void @_Z15test_uuidofTypeI10TestStructEvPPv(i8** null)
52 // CHECK: call void @_Z15test_uuidofExprI9HasMemberEvPPv(i8** null)
53 
54 // CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC1Ev
55 // CHECK: define linkonce_odr void @_Z15test_uuidofTypeI10TestStructEvPPv
56 // CHECK: define linkonce_odr void @_Z15test_uuidofExprI9HasMemberEvPPv
57 // CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructL_Z42_GUID_eafa1952_66f8_438b_8fba_af1bbae42191EEC2Ev
58