[cfe-commits] r65562 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-13.m
steve naroff
snaroff at apple.com
Thu Feb 26 11:54:40 PST 2009
On Feb 26, 2009, at 2:31 PM, Sebastian Redl wrote:
> steve naroff wrote:
>>
>> On Feb 26, 2009, at 2:16 PM, Sebastian Redl wrote:
>>
>>> Steve Naroff wrote:
>>>> Author: snaroff
>>>> Date: Thu Feb 26 13:11:32 2009
>>>> New Revision: 65562
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=65562&view=rev
>>>> Log:
>>>> Fix <rdar://problem/6574319> clang issues error on 'readonly'
>>>> property with a defaul setter attribute.
>>>>
>>>> Needed to make isPropertyReadonly() non-const (for this fix to
>>>> compile). I imagine there's a way to retain the const-ness, however
>>>> I have more important fish to fry.
>>>>
>>>> + // Lastly, look through the implementation (if one is in scope).
>>>> + if (ObjCImplementationDecl *ImpDecl =
>>>> + ObjCImplementations[IDecl->getIdentifier()])
>>>> + if (ImpDecl->getInstanceMethod(PDecl->getSetterName()))
>>>> + return false;
>>>> return true;
>>>> }
>>>>
>>> Wouldn't it suffice to make ImpDecl here a pointer-to-const?
>>>
>>
>> Still getting errors...
>>
>> llvm[2]: Compiling SemaDeclObjC.cpp for Debug build
>> SemaDeclObjC.cpp: In member function ‘bool
>> clang::Sema::isPropertyReadonly(clang::ObjCPropertyDecl*,
>> clang::ObjCInterfaceDecl*) const’:
>> SemaDeclObjC.cpp:763: error: no match for ‘operator[]’ in
> Right, I forgot. The standard associative map (std::map,
> llvm::DenseMap,
> ...) doesn't have a non-const [], because that operator wants to
> insert
> if it doesn't find the value in question.
>
> The correct code uses find() and would be something horrible like
> this:
>
> llvm::DenseMap<IdentifierInfo*,
> ObjCImplementationDecl*>::const_iterator
> it = ObjCImplementations.find(IDecl->getIdentifier());
> if (it != ObjCImplementations.end())
> if ((*it)->getInstanceMethod(PDecl->getSetterName()))
> return false;
> return true;
>
Yuck. I think I'll stick with what I had:-) If anyone feels strongly
about retaining the const specifier, I'm happy to change it.
Thanks for your help,
snaroff
> Sebastian
More information about the cfe-commits
mailing list