Quantcast

Rules for FunctionDecls without bodies

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Rules for FunctionDecls without bodies

Daniel Marjamäki via cfe-dev
I am looking at some debug information for the following code:

int main (int argc, char const *argv[])
{
    struct point_tag {
        int x;
        int y;
        char padding[0];
    };

LLDB has constructed the struct like this:

(lldb) p ((TagDecl*)0x1102eed78)->dump()
CXXRecordDecl 0x1102eed78 <<invalid sloc>> <invalid sloc> struct point_tag definition
|-FieldDecl 0x1102eeeb8 <<invalid sloc>> <invalid sloc> x 'int'
|-FieldDecl 0x1102eef00 <<invalid sloc>> <invalid sloc> y 'int'
`-FieldDecl 0x1102eef78 <<invalid sloc>> <invalid sloc> padding 'char []'
(lldb) p ((TagDecl*)0x1102eed78)->getContext()
error: no member named 'getContext' in 'clang::TagDecl'
(lldb) p ((TagDecl*)0x1102eed78)->getDeclContext()
(clang::DeclContext *) $22 = 0x00000001102eed10

But the context doesn't have a body.

(lldb) p ((FunctionDecl*)$22)
(clang::FunctionDecl *) $23 = 0x00000001102eecd0
(lldb) p $23->dump()
FunctionDecl 0x1102eecd0 <<invalid sloc>> <invalid sloc> main 'int (int, const char **)' extern
|-ParmVarDecl 0x1102eec10 <<invalid sloc>> <invalid sloc> argc 'int'
`-ParmVarDecl 0x1102eec70 <<invalid sloc>> <invalid sloc> argv 'const char **'
(lldb) p $23->getBody()
(clang::Stmt *) $24 = 0x0000000000000000

Are these legal ASTs?  It seems like with things set up the way they are, point_tag can't be looked up if you only have the FunctionDecl. 

Sean

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...