[PATCH] Expose AST Record layout attributes to libclang

Loïc Jaquemet loic.jaquemet at gmail.com
Mon Feb 11 21:51:38 PST 2013


Hello,

This patch is 3 functions in libclang to get more Record Layout
information from the AST when using libclang.

I am trying to implement the python ctypeslib record generator by
replacing gccxml with libclang.

Files:
001:
 include/clang-c/Index.h
 tools/libclang/libclang.exports
 tools/libclang/CXType.cpp
002:
 test/Index/record-layout.cpp
 test/Index/record-layout.c
 test/Index/record-layout-virtual.cpp
 tools/c-index-test/c-index-test.c
003:
 bindings/python/clang/cindex.py
004:
 bindings/python/tests/cindex/util.py
 bindings/python/tests/cindex/test_type.py


Here is the latest version following your comments.
Given that I'm pretty sure the -m32/-m64 flag is not sufficient. lets
say this is a draft for you to comment on.

PS:
I get a assertion error if record-layout-virtual.cpp is renamed as
record-layout-virtual.c.
c-index-test: /home/jal/compil/llvm/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2470:
const clang::ASTRecordLayout&
clang::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const:
Assertion `D && "Cannot get layout of forward declarations!"' failed.

I am not sure that error ( provoked by c++ in a .c file ) is actually
part of my code or not.
I have no knowledge of forward declaration or solution to that problem.

-- 
Loïc Jaquemet
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expose-ast-record-layout-001
Type: application/octet-stream
Size: 3620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130212/cede4c77/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expose-ast-record-layout-002-tests
Type: application/octet-stream
Size: 15745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130212/cede4c77/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expose-ast-record-layout-003-python-bindings
Type: application/octet-stream
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130212/cede4c77/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expose-ast-record-layout-004-python-bindings-tests
Type: application/octet-stream
Size: 2159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130212/cede4c77/attachment-0003.obj>


More information about the cfe-commits mailing list