[cfe-dev] abort calling getTypeSize
Peeter Joot
peeter.joot at gmail.com
Mon Feb 25 09:24:10 PST 2013
Thanks Dmitri,
That avoids the abort with that particular template in our source.
However, for other places, isDependentType() seems a bit more stringent
than required. For example, the m_pNext field of the following class:
template <class DATA_TYP>
struct noInheritance
{
noInheritance<DATA_TYP>* m_pNext;
int m_priKey;
};
gets flagged as a dependent type, yet this is something that one should
logically be able to execute getTypeSize() on [and in fact one can without
trouble].
This is my current visitor source:
bool VisitFieldDecl( FieldDecl * f )
{
RecordDecl * r = f->getParent() ;
TypeSourceInfo * pThisFieldSourceInfo = f->getTypeSourceInfo() ;
TypeLoc thisFieldTypeLoc = pThisFieldSourceInfo->getTypeLoc() ;
const QualType & thisFieldQualType = thisFieldTypeLoc.getType() ;
const Type * t = thisFieldTypeLoc.getTypePtr() ;
const QualType & theMembersClassType = m_context.getRecordType( r ) ;
if ( !t->isDependentType() )
{
size_t szInBits = m_context.getTypeSize( thisFieldQualType ) ;
size_t offsetInBits = m_context.getFieldOffset( f ) ;
cout
<< "[" << offsetInBits/8 << "]:\t"
<< theMembersClassType.getAsString( m_pp ) << "::" <<
thisFieldQualType.getAsString( m_pp ) << "\t" << f->getNameAsString()
<< "\tsize: " << szInBits/8 << endl ;
;
}
return true ;
}
any suggestion how to weaken the isDependentType() checking here to allow
it's use on the field noInheritance::m_pNext above, but still avoid the
abort that occurs with OSS_STRUCTURE_PAD_DELTA::pad?
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130225/384149d5/attachment.html>
More information about the cfe-dev
mailing list