[cfe-dev] abort calling getTypeSize

Peeter Joot peeter.joot at gmail.com
Sun Feb 24 14:46:00 PST 2013


With the following sample code:

template <class T, size_t extraSize >
struct OSS_STRUCTURE_PAD_DELTA : public T
{
   char pad[ extraSize ] ;
} ;

and an ast visitor that calls getTypeSize():

bool VisitFieldDecl( FieldDecl * f )
{
   RecordDecl * r = f->getParent() ;
   const QualType & theMembersClassType = m_context.getRecordType( r ) ;

   TypeSourceInfo * pThisFieldSourceInfo = f->getTypeSourceInfo() ;

   TypeLoc thisFieldTypeLoc = pThisFieldSourceInfo->getTypeLoc() ;

   const QualType & thisFieldQualType = thisFieldTypeLoc.getType() ;

   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 ;
}

I get the following abort:

t.C:5:20: error: unknown type name 'size_t'
template <class T, size_t extraSize >
                   ^
Should not see dependent types
UNREACHABLE executed at
/home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/AST/ASTContext.cpp:1322!

Program received signal SIGABRT, Aborted.
0x00002aaaab39ef45 in raise () from /lib64/libc.so.6
(gdb) where
#0  0x00002aaaab39ef45 in raise () from /lib64/libc.so.6
#1  0x00002aaaab3a0340 in abort () from /lib64/libc.so.6
#2  0x0000000000f024b8 in llvm::llvm_unreachable_internal (msg=0x132c728
"Should not see dependent types",
    file=0x132bd18
"/home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/AST/ASTContext.cpp",
line=1322)
    at
/home/hotellnx94/peeterj/clang/sources/llvm/lib/Support/ErrorHandling.cpp:98
#3  0x0000000000c1c5e4 in clang::ASTContext::getTypeInfoImpl
(this=0x1b36050, T=0x1b55aa0)
    at
/home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/AST/ASTContext.cpp:1322
#4  0x0000000000c1c509 in clang::ASTContext::getTypeInfo (this=0x1b36050,
T=0x1b55aa0)
    at
/home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/AST/ASTContext.cpp:1301
#5  0x000000000046229d in clang::ASTContext::getTypeInfo (this=0x1b36050,
T=...)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/ASTContext.h:1473
#6  0x0000000000462221 in clang::ASTContext::getTypeSize (this=0x1b36050,
T=...)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/ASTContext.h:1478
#7  0x0000000000462068 in MyASTVisitor::VisitFieldDecl
(this=0x7fffffffc010, f=0x1b55b00) at ./memberdumper.h:25
#8  0x0000000000461f75 in
clang::RecursiveASTVisitor<MyASTVisitor>::WalkUpFromFieldDecl
(this=0x7fffffffc010, D=0x1b55b00)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/DeclNodes.inc:313
#9  0x00000000004208bd in
clang::RecursiveASTVisitor<MyASTVisitor>::TraverseFieldDecl
(this=0x7fffffffc010, D=0x1b55b00)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/RecursiveASTVisitor.h:1665
#10 0x000000000041e0f4 in
clang::RecursiveASTVisitor<MyASTVisitor>::TraverseDecl
(this=0x7fffffffc010, D=0x1b55b00)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/DeclNodes.inc:313
#11 0x0000000000421993 in
clang::RecursiveASTVisitor<MyASTVisitor>::TraverseDeclContextHelper
(this=0x7fffffffc010, DC=0x1b3e2d8)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/RecursiveASTVisitor.h:1232
#12 0x000000000041fe5a in
clang::RecursiveASTVisitor<MyASTVisitor>::TraverseCXXRecordDecl
(this=0x7fffffffc010, D=0x1b3e2a0)
    at
/home/hotellnx94/peeterj/clang/debug48rt/include/clang/AST/RecursiveASTVisitor.h:1588

Is this a known problem?  I'm running a recent snapshot:

Path: .
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 175922
Node Kind: directory
Schedule: normal
Last Changed Author: ahatanak
Last Changed Rev: 175920
Last Changed Date: 2013-02-22 16:10:03 -0500 (Fri, 22 Feb 2013)
Properties Last Updated: 2013-02-22 16:49:48 -0500 (Fri, 22 Feb 2013)

-- 
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130224/ad9f09af/attachment.html>


More information about the cfe-dev mailing list