forked from OSchip/llvm-project
Patch to allow mangling of microsoft’s __uuidof expression for the Itanium ABI
when under -fms-extensions. Reviewed by John McCall. //rdar://17784718 llvm-svn: 218384
This commit is contained in:
parent
d5635cdd7f
commit
945a08d7cd
|
@ -2655,7 +2655,6 @@ recurse:
|
|||
case Expr::ArrayTypeTraitExprClass:
|
||||
case Expr::ExpressionTraitExprClass:
|
||||
case Expr::VAArgExprClass:
|
||||
case Expr::CXXUuidofExprClass:
|
||||
case Expr::CUDAKernelCallExprClass:
|
||||
case Expr::AsTypeExprClass:
|
||||
case Expr::PseudoObjectExprClass:
|
||||
|
@ -2670,6 +2669,20 @@ recurse:
|
|||
break;
|
||||
}
|
||||
|
||||
case Expr::CXXUuidofExprClass: {
|
||||
const CXXUuidofExpr *UE = cast<CXXUuidofExpr>(E);
|
||||
if (UE->isTypeOperand()) {
|
||||
QualType UuidT = UE->getTypeOperand(Context.getASTContext());
|
||||
Out << "u8__uuidoft";
|
||||
mangleType(UuidT);
|
||||
} else {
|
||||
Expr *UuidExp = UE->getExprOperand();
|
||||
Out << "u8__uuidofz";
|
||||
mangleExpression(UuidExp, Arity);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Even gcc-4.5 doesn't mangle this.
|
||||
case Expr::BinaryConditionalOperatorClass: {
|
||||
DiagnosticsEngine &Diags = Context.getDiags();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-pc-win32 -g %s -o - -std=c++11 | FileCheck %s
|
||||
// RUN: not %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-unknown-unknown -g %s -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-ITANIUM
|
||||
// RUN: %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-unknown-unknown -g %s -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-ITANIUM
|
||||
|
||||
// CHECK: metadata [[TGIARGS:![0-9]*]], null} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>]
|
||||
// CHECK: [[TGIARGS]] = metadata !{metadata [[TGIARG1:![0-9]*]]}
|
||||
|
@ -8,7 +8,7 @@
|
|||
// CHECK: [[CONST_GUID]] = {{.*}}, metadata [[GUID:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _GUID]
|
||||
// CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID]
|
||||
|
||||
// CHECK-ITANIUM: error: cannot yet mangle expression type CXXUuidofExpr
|
||||
// CHECK-ITANIUM: metadata !"_ZTS9tmpl_guidIXadu8__uuidoft4uuidEE"} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>]
|
||||
|
||||
struct _GUID;
|
||||
template <const _GUID *>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-unknown-unknown -fms-extensions | FileCheck %s
|
||||
// rdar://17784718
|
||||
|
||||
typedef struct _GUID
|
||||
{
|
||||
unsigned int Data1;
|
||||
unsigned short Data2;
|
||||
unsigned short Data3;
|
||||
unsigned char Data4[ 8 ];
|
||||
} GUID;
|
||||
|
||||
|
||||
template < typename T, const GUID & T_iid = __uuidof(T)>
|
||||
class UUIDTest
|
||||
{
|
||||
public:
|
||||
UUIDTest() { }
|
||||
};
|
||||
|
||||
struct __declspec(uuid("EAFA1952-66F8-438B-8FBA-AF1BBAE42191")) TestStruct
|
||||
{
|
||||
int foo;
|
||||
};
|
||||
|
||||
template <class T> void test_uuidofType(void *arg[sizeof(__uuidof(T))] = 0) {}
|
||||
|
||||
template <class T> void test_uuidofExpr(void *arg[sizeof(__uuidof(T::member))] = 0) {}
|
||||
|
||||
struct HasMember { typedef TestStruct member; };
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
|
||||
UUIDTest<TestStruct> uuidof_test;
|
||||
test_uuidofType<TestStruct>();
|
||||
test_uuidofExpr<HasMember>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK: define i32 @main
|
||||
// CHECK: call void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC1Ev
|
||||
// CHECK: call void @_Z15test_uuidofTypeI10TestStructEvPPv(i8** null)
|
||||
// CHECK: call void @_Z15test_uuidofExprI9HasMemberEvPPv(i8** null)
|
||||
|
||||
// CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC1Ev
|
||||
// CHECK: define linkonce_odr void @_Z15test_uuidofTypeI10TestStructEvPPv
|
||||
// CHECK: define linkonce_odr void @_Z15test_uuidofExprI9HasMemberEvPPv
|
||||
// CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC2Ev
|
Loading…
Reference in New Issue