[cfe-commits] r152968 - /cfe/trunk/lib/Sema/SemaExprMember.cpp

Douglas Gregor dgregor at apple.com
Sat Mar 17 12:31:02 PDT 2012



Sent from my iPhone

On Mar 17, 2012, at 9:50 AM, Fariborz Jahanian <fjahanian at apple.com> wrote:

> I think after ivar name is corrected, you should call lookupInstanceVariable again instead of looking up ivar out of the box.
> This makes sure that ivar is always looked up with the same lookup algorithm (and ClassDeclared is set same way)

IMO, the right answer here is to fold lookupInstanceVariable into Sema's normal lookup routines, so there's just one, always-correct way to find ivars. 

> . A positive test case will clarify this issue
> (even though it does not show the original crashed bug).
> 
> - Fariborz
> 
> 
> On Mar 16, 2012, at 5:53 PM, Ted Kremenek wrote:
> 
>> Author: kremenek
>> Date: Fri Mar 16 19:53:39 2012
>> New Revision: 152968
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=152968&view=rev
>> Log:
>> Fix crash on invalid code.  I've tried to produce a reduced test case, but when I do the specific crash is hidden.  Fixes <rdar://problem/11063594>.
>> 
>> Modified:
>>   cfe/trunk/lib/Sema/SemaExprMember.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=152968&r1=152967&r2=152968&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Fri Mar 16 19:53:39 2012
>> @@ -1127,7 +1127,7 @@
>>                              << BaseExpr.get()->getSourceRange()))
>>      return ExprError();
>> 
>> -    ObjCInterfaceDecl *ClassDeclared;
>> +    ObjCInterfaceDecl *ClassDeclared = 0;
>>    ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
>> 
>>    if (!IV) {
>> @@ -1145,6 +1145,13 @@
>>                                          IV->getNameAsString());
>>        Diag(IV->getLocation(), diag::note_previous_decl)
>>          << IV->getDeclName();
>> +        
>> +        // Figure out the class that declares the ivar.
>> +        assert(!ClassDeclared);
>> +        Decl *D = cast<Decl>(IV->getDeclContext());
>> +        if (ObjCCategoryDecl *CAT = dyn_cast<ObjCCategoryDecl>(D))
>> +          D = CAT->getClassInterface();
>> +        ClassDeclared = cast<ObjCInterfaceDecl>(D);
>>      } else {
>>        if (IsArrow && IDecl->FindPropertyDeclaration(Member)) {
>>          Diag(MemberLoc, 
>> @@ -1160,6 +1167,8 @@
>>        return ExprError();
>>      }
>>    }
>> +    
>> +    assert(ClassDeclared);
>> 
>>    // If the decl being referenced had an error, return an error for this
>>    // sub-expr without emitting another error, in order to avoid cascading
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list