[cfe-dev] abort calling getTypeSize

Peeter Joot peeter.joot at gmail.com
Mon Feb 25 14:16:18 PST 2013

On Mon, Feb 25, 2013 at 3:08 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote:

> I guess you are calling getFieldOffset for a field that has a
> dependent type?  You could dump the record or the field to see what it
> is (->dump()).

(gdb) p RD->dump()
CXXRecordDecl 0x391a9f0 <.../include/sqlm_metrics.h:2218:4, line:2228:4>
struct MetricsPartition
|-FullComment 0x3922c30 <line:2217:7, col:35>
| `-ParagraphComment 0x3922c00 <col:7, col:35>
|   `-TextComment 0x3922bd0 <col:7, col:35> Text=" Metrics Partition
|-CXXRecordDecl 0x391ab00 <line:2218:4, col:11> struct MetricsPartition
|-FieldDecl 0x391aba0 <line:2221:7, col:25> metricData 'T'

You were right that this appears to be a dependent type.  The declaration
was an embedded struct within another explicit template class:

   template <class T>
   class metricsOuter: public allocatorObj

      Uint64 m_numPartitions;

      struct MetricsPartition
         T  metricData;

This inner class MetricsPartition doesn't get identitifed as a template
class by getDescribeClassTemplate().  The code I'd used for that
identification was:

   bool VisitCXXRecordDecl( CXXRecordDecl * r )
      if ( r && r->getDescribedClassTemplate() )
         r = r->getInstantiatedFromMemberClass() ;

      if ( r && r->isThisDeclarationADefinition() )

This code properly identifies the outer class as a template class, but not
the inner, perhaps because the template nature of that class is implicit.
 Is there a way to identify such an implicit template class as such (or
perhaps just identify some way that this class has dependent members
(without finding out the hard way with the abort)).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130225/8742ebd9/attachment.html>

More information about the cfe-dev mailing list