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

Jim Goodnow II jim at thegoodnows.net
Wed Dec 22 20:42:48 PST 2010


How about:

class A {
};

class B : public A {
};

template <typename T>
class C {
public:
   T *ptr();
};

void foo() {
   A *op;
   B *undefined;
   C<B> unknown;

   op = unknown.ptr(); // will generate Assert
   op = undefined; // will generate Assert
}

  - jim

At 07:53 PM 12/22/2010, Xu Zhongxing wrote:
>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 
><<mailto:jim at thegoodnows.net>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>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>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
><mailto:cfe-commits at cs.uiuc.edu>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 - <http://www.avg.com>www.avg.com
>Version: 9.0.869 / Virus Database: 271.1.1/3260 
>- Release Date: 11/15/10 23:34:00
>
>
>
>
>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/20101222/a68bdcfe/attachment.html>


More information about the cfe-commits mailing list