[cfe-commits] r131066 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp
Douglas Gregor
dgregor at apple.com
Mon May 9 16:24:11 PDT 2011
On May 9, 2011, at 3:45 PM, Francois Pichet wrote:
> On Mon, May 9, 2011 at 3:00 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>
>> On May 8, 2011, at 3:02 AM, Francois Pichet wrote:
>>
>>> Author: fpichet
>>> Date: Sun May 8 05:02:20 2011
>>> New Revision: 131066
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=131066&view=rev
>>> Log:
>>> Look at all the record redeclaration when looking for a uuid attribute.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=131066&r1=131065&r2=131066&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun May 8 05:02:20 2011
>>> @@ -385,13 +385,14 @@
>>> else if (QT->isArrayType())
>>> Ty = cast<ArrayType>(QT)->getElementType().getTypePtr();
>>>
>>> - // Loop all class definition and declaration looking for an uuid attribute.
>>> + // Loop all record redeclaration looking for an uuid attribute.
>>> CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
>>> - while (RD) {
>>> - if (UuidAttr *Uuid = RD->getAttr<UuidAttr>())
>>> + for (CXXRecordDecl::redecl_iterator I = RD->redecls_begin(),
>>> + E = RD->redecls_end(); I != E; ++I) {
>>> + if (UuidAttr *Uuid = I->getAttr<UuidAttr>())
>>> return Uuid;
>>> - RD = RD->getPreviousDeclaration();
>>> }
>>> +
>>> return 0;
>>> }
>>
>>
>> Usually, we merge attributes from prior declarations to later declarations, so that we don't need to perform walks over all redeclarations. That would be a better solution, unless you're seeing a case where MSVC is allowing us to pick up a UUID attribute from a later declaration?
>>
>
> yes MSVC will pick a UUID from a later declaration:
>
> as in:
>
> struct A;
> struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) A;
Sure, but how does this affect the UUID operator? Is it something like:
struct A;
template<typename T>
void f() {
__uuidof(A);
}
struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) A;
?
I could certainly imagine MSVC allowing that. (A test to that effect would be nice)
- Doug
More information about the cfe-commits
mailing list