<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 14, 2014 at 4:40 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Mon Jul 14 18:40:24 2014<br>
New Revision: 213016<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213016&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213016&view=rev</a><br>
Log:<br>
AST: Fix __uuidof for template specializations<br>
<br>
While we previously supported __uuidof applied to a template<br>
specialization, we would only find the uuid attribute if it was applied<br>
to the template argument. We would erroneously ignore the uuid<br>
attribute on the specialization itself.<br>
<br>
This is required to parse Windows Runtime C++ Template Library headers.<br>
<br>
Added:<br>
cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp<br>
Modified:<br>
cfe/trunk/lib/AST/ExprCXX.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/ExprCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=213016&r1=213015&r2=213016&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=213016&r1=213015&r2=213016&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Jul 14 18:40:24 2014<br>
@@ -68,6 +68,11 @@ const UuidAttr *CXXUuidofExpr::GetUuidAt<br>
if (!RD)<br>
return nullptr;<br>
<br>
+ // Loop over all record redeclarations looking for a uuid attribute.<br>
+ for (const TagDecl *I : RD->redecls())<br>
+ if (const UuidAttr *Uuid = I->getAttr<UuidAttr>())<br>
+ return Uuid;<br></blockquote><div><br></div><div>Given that this is an inherited attribute, do you really need to walk over the redeclarations looking for it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
// __uuidof can grab UUIDs from template arguments.<br>
if (ClassTemplateSpecializationDecl *CTSD =<br>
dyn_cast<ClassTemplateSpecializationDecl>(RD)) {<br>
@@ -106,11 +111,6 @@ const UuidAttr *CXXUuidofExpr::GetUuidAt<br>
return UuidForRD;<br>
}<br>
<br>
- // Loop over all record redeclarations looking for a uuid attribute.<br>
- for (const TagDecl *I : RD->redecls())<br>
- if (const UuidAttr *Uuid = I->getAttr<UuidAttr>())<br>
- return Uuid;<br>
-<br>
return nullptr;<br>
}<br>
<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp?rev=213016&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp?rev=213016&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp Mon Jul 14 18:40:24 2014<br>
@@ -0,0 +1,37 @@<br>
+// RUN: %clang_cc1 -emit-llvm %s -o - -DDEFINE_GUID -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefix=CHECK<br>
+<br>
+struct _GUID;<br>
+<br>
+template <typename><br>
+struct X {<br>
+};<br>
+<br>
+struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) A {};<br>
+<br>
+struct B {};<br>
+<br>
+template <><br>
+struct __declspec(uuid("{BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB}")) X<B> {};<br>
+<br>
+struct __declspec(uuid("{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}")) C {};<br>
+<br>
+const _GUID &xa = __uuidof(X<A>);<br>
+// CHECK-DAG: @"\01?xa@@3ABU_GUID@@B" = {{.*}} @_GUID_aaaaaaaa_aaaa_aaaa_aaaa_aaaaaaaaaaaa<br>
+<br>
+const _GUID &xb = __uuidof(X<B>);<br>
+// CHECK-DAG: @"\01?xb@@3ABU_GUID@@B" = {{.*}} @_GUID_bbbbbbbb_bbbb_bbbb_bbbb_bbbbbbbbbbbb<br>
+const _GUID &xc = __uuidof(X<C>);<br>
+// CHECK-DAG: @"\01?xc@@3ABU_GUID@@B" = {{.*}} @_GUID_cccccccc_cccc_cccc_cccc_cccccccccccc<br>
+<br>
+template <><br>
+struct __declspec(uuid("{DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD}")) X<C> {};<br>
+<br>
+template <typename><br>
+struct __declspec(uuid("{EEEEEEEE-EEEE-EEEE-EEEE-EEEEEEEEEEEE}")) Y {<br>
+};<br>
+<br>
+const _GUID &xd = __uuidof(X<C>);<br>
+// CHECK-DAG: @"\01?xd@@3ABU_GUID@@B" = {{.*}} @_GUID_dddddddd_dddd_dddd_dddd_dddddddddddd<br>
+<br>
+const _GUID &yd = __uuidof(Y<X<C> >);<br>
+// CHECK-DAG: @"\01?yd@@3ABU_GUID@@B" = {{.*}} @_GUID_dddddddd_dddd_dddd_dddd_dddddddddddd<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>