<html>
<body>
How about:<br><br>
class A {<br>
};<br><br>
class B : public A {<br>
};<br><br>
template <typename T><br>
class C {<br>
public:<br>
T *ptr();<br>
};<br><br>
void foo() {<br>
A *op;<br>
B *undefined;<br>
C<B> unknown;<br><br>
op = unknown.ptr(); // will generate Assert<br>
op = undefined; // will generate Assert<br>
}<br><br>
- jim<br><br>
At 07:53 PM 12/22/2010, Xu Zhongxing wrote:<br>
<blockquote type=cite class=cite cite="">This is surely not complete. But
I prefer a test case before inserting the code.<br><br>
On Wed, Dec 22, 2010 at 8:50 PM, Jim Goodnow II
<<a href="mailto:jim@thegoodnows.net">jim@thegoodnows.net</a>>
wrote:<br>
<dl>
<dd>I was looking at the same situation, but you beat me to it. There is
an addition that does need to be made:<br><br>
<dd>Â if (!isa<loc::MemRegionVal>(derived))<br>
<dd>Â Â return derived;<br><br>
<dd>needs to be inserted before the cast<> for UnknownVals and
UndefinedVals to prevent an Assert in the cast<> call.<br><br>
<dd>Â - jim<br><br>
<br>
<dd>At 12:12 AM 12/22/2010, Zhongxing Xu wrote:<br>
<dl>
<dd>Author: zhongxingxu<br>
<dd>Date: Wed Dec 22 02:12:57 2010<br>
<dd>New Revision: 122393<br><br>
<dd>URL:
<a href="http://llvm.org/viewvc/llvm-project?rev=122393&view=rev">
http://llvm.org/viewvc/llvm-project?rev=122393&view=rev</a><br>
<dd>Log:<br>
<dd>The base type is not always pointer type. We may cast to a base
reference.<br><br>
<dd>Modified:<br>
<dd>Â Â cfe/trunk/lib/Checker/RegionStore.cpp<br><br>
<dd>Modified: cfe/trunk/lib/Checker/RegionStore.cpp<br>
<dd>URL:
<a href="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</a>
<br>
<dd>
==============================================================================<br>
<dd>--- cfe/trunk/lib/Checker/RegionStore.cpp (original)<br>
<dd>+++ cfe/trunk/lib/Checker/RegionStore.cpp Wed Dec 22 02:12:57
2010<br>
<dd>@@ -807,9 +807,15 @@<br>
<dd>Â return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx,
ArrayR, Ctx));<br>
<dd>Â }<br><br>
<dd>-SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType
basePtrType) {<br>
<dd>- Â const CXXRecordDecl *baseDecl =
basePtrType->getCXXRecordDeclForPointerType();<br>
<dd>+SVal RegionStoreManager::evalDerivedToBase(SVal derived, QualType
baseType) {<br>
<dd>+ Â const CXXRecordDecl *baseDecl;<br>
<dd>+ Â if (baseType->isPointerType())<br>
<dd>+ Â Â baseDecl =
baseType->getCXXRecordDeclForPointerType();<br>
<dd>+ Â else<br>
<dd>+ Â Â baseDecl = baseType->getAsCXXRecordDecl();<br>
<dd>+<br>
<dd>Â assert(baseDecl && "not a
CXXRecordDecl?");<br>
<dd>+<br>
<dd>Â loc::MemRegionVal &derivedRegVal =
cast<loc::MemRegionVal>(derived);<br>
<dd>Â const MemRegion *baseReg =<br>
<dd>Â Â MRMgr.getCXXBaseObjectRegion(baseDecl,
derivedRegVal.getRegion());<br><br>
<br>
<dd>_______________________________________________<br>
<dd>cfe-commits mailing list<br>
<dd><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a>
<br>
<dd>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" eudora="autourl">
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br><br>
<br>
<dd>Internal Virus Database is out of date.<br>
<dd>Checked by AVG - <a href="http://www.avg.com">www.avg.com</a><br>
<dd>Version: 9.0.869 / Virus Database: 271.1.1/3260 - Release Date:
11/15/10 23:34:00<br><br>
</dl><br>
</dl><br><br>
Internal Virus Database is out of date.<br>
Checked by AVG -
<a href="http://www.avg.com/" eudora="autourl">www.avg.com</a> <br>
Version: 9.0.869 / Virus Database: 271.1.1/3260 - Release Date: 11/15/10
23:34:00</blockquote></body>
</html>