Hi,
I'm parsing an ObjC source file with libclang by using Python bindings. Parsing itself works fine but since I'm parsing source files which #import framework headers such as UIKit.h and Foundation.h, the parsing is a pretty heavy operation even for the most simple main source files. I would like to use precompiled prefix headers to make the parsing faster, but apparently I'm doing something wrong. Here is the Python code I use:
I /think/ you should be using Index.read() instead of Index.parse() to
load PCH files. Try:
tu = index.read(sourceFile)
Hi Gregory,
index.read is mapped to the clang_createTranslationUnit function in libclang, which is documented to "Create a translation unit from an AST file (-emit-ast).". Since the precompiled header isn't AST file, I don't think that function should be used.
I thought a PCH file could be produced by saving a translation unit with the appropriate save flags. The docs for clang_saveTranslationUnit [1] and the corresponding save flags [2] seem to indicate this.
Do I have a wrong understanding here?
[1] http://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga3abe9df81f9fef269d737d82720c1d33
[2] http://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#gab1e4965c1ebe8e41d71e90203a723fe9