Sam Price
2013-Dec-10 22:09 UTC
[LLVMdev] libcang python bindings and working with macros question
How do I obtain the data that a macro points to, both expanded and unexpanded. in example I have a file named "blah.c" with the following. """ #define TESTA 1 #define TESTB 2 + TESTA """ I modified util.py's get_cursor to look at the displayname also, as spelling won't match the macroname. """ for cursor in children: if cursor.spelling == spelling: return cursor if cursor.displayname == spelling: return cursor """ import scripts.clang.cindex as cindex from scripts.util import get_cursor index = cindex.Index.create() t = cindex.TranslationUnit tu = index.parse('blah.c',[ ] ,options=t.PARSE_DETAILED_PROCESSING_RECORD | t.PARSE_PRECOMPILED_PREAMBLE) cursor = tu.cursor z = get_cursor(cursor,'TESTB') fid = open('blah.c') raw = fid.read() fid.close() print raw[z.extent.start.offset:z.extent.end.offset] this outputs TESTB 2 + TESTA How should I go about obtaining the expanded macro of 3. -- Thank you, Sam Price -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131210/4d56d8e8/attachment.html>
Possibly Parallel Threads
- [LLVMdev] libcang python bindings and working with macros question
- [LLVMdev] [libclang] Python bindings bug.
- [LLVMdev] Cygwin patches for 2.7
- [LLVMdev] Cygwin patches for 2.7
- [LLVMdev] patch for CIndex linakge error on Mingw, set the proper LINKER_LANGUAGE for CIndex and c-index-test