[cfe-commits] r122393 - /cfe/trunk/lib/Checker/RegionStore.cpp

Xu Zhongxing xuzhongxing at gmail.com
Wed Dec 22 19:53:26 PST 2010


This is surely not complete. But I prefer a test case before inserting the
code.

On Wed, Dec 22, 2010 at 8:50 PM, Jim Goodnow II <jim at thegoodnows.net> wrote:

> I was looking at the same situation, but you beat me to it. There is an
> addition that does need to be made:
>
>  if (!isa<loc::MemRegionVal>(derived))
>    return derived;
>
> needs to be inserted before the cast<> for UnknownVals and UndefinedVals to
> prevent an Assert in the cast<> call.
>
>  - jim
>
>
> At 12:12 AM 12/22/2010, Zhongxing Xu wrote:
>
>> Author: zhongxingxu
>> Date: Wed Dec 22 02:12:57 2010
>> New Revision: 122393
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=122393&view=rev
>> Log:
>> The base type is not always pointer type. We may cast to a base reference.
>>
>> Modified:
>>    cfe/trunk/lib/Checker/RegionStore.cpp
>>
>> Modified: cfe/trunk/lib/Checker/RegionStore.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=122393&r1=122392&r2=122393&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Checker/RegionStore.cpp (original)
>> +++ cfe/trunk/lib/Checker/RegionStore.cpp Wed Dec 22 02:12:57 2010
>> @@ -807,9 +807,15 @@
>>   return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, ArrayR,
>> Ctx));
>>  }
>>
>> -SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType
>> basePtrType) {
>> -  const CXXRecordDecl *baseDecl =
>> basePtrType->getCXXRecordDeclForPointerType();
>> +SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType
>> baseType) {
>> +  const CXXRecordDecl *baseDecl;
>> +  if (baseType->isPointerType())
>> +    baseDecl = baseType->getCXXRecordDeclForPointerType();
>> +  else
>> +    baseDecl = baseType->getAsCXXRecordDecl();
>> +
>>   assert(baseDecl && "not a CXXRecordDecl?");
>> +
>>   loc::MemRegionVal &derivedRegVal = cast<loc::MemRegionVal>(derived);
>>   const MemRegion *baseReg =
>>     MRMgr.getCXXBaseObjectRegion(baseDecl, derivedRegVal.getRegion());
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>> Internal Virus Database is out of date.
>> Checked by AVG - www.avg.com
>> Version: 9.0.869 / Virus Database: 271.1.1/3260 - Release Date: 11/15/10
>> 23:34:00
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101223/179564cc/attachment.html>


More information about the cfe-commits mailing list