diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 3173a8a079b9..4717174b4a4a 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -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(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(); diff --git a/clang/test/CodeGenCXX/debug-info-uuid.cpp b/clang/test/CodeGenCXX/debug-info-uuid.cpp index 6137400de07c..417e44c3ef07 100644 --- a/clang/test/CodeGenCXX/debug-info-uuid.cpp +++ b/clang/test/CodeGenCXX/debug-info-uuid.cpp @@ -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 diff --git a/clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp b/clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp new file mode 100644 index 000000000000..9019aa8c9217 --- /dev/null +++ b/clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp @@ -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 void test_uuidofType(void *arg[sizeof(__uuidof(T))] = 0) {} + +template void test_uuidofExpr(void *arg[sizeof(__uuidof(T::member))] = 0) {} + +struct HasMember { typedef TestStruct member; }; + +int main(int argc, const char * argv[]) +{ + + UUIDTest uuidof_test; + test_uuidofType(); + test_uuidofExpr(); + 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