How to write and use chained PCHs
Yao SHEN
yaoshen at andrew.cmu.edu
Tue Aug 13 06:19:53 PDT 2013
Hello,
This is Yao Shen. I got a problem recently and hope someone here can
help me.
I am using llvm+clang to parse c/c++ codes. My objective is to do some
instrumentations towards these codes by inserting instructions into the
codes.
The problem is: the codes are somewhat large. They usually larger than
50M. And there are a lot of header files shared by c/c++ files. All of
these make the parsing process very slowly (> 30 minutes).
So I am think if I can use PCH. In the first step, I will compile all of
the header files into PCHs. And then when parsing c/c++ files, I load
corresponding PCH files in the PPCallback using ASTReader. It works when
the header file is simple (not including other headers). However, if
there is a chained including, it cannot work.
For example, if A.h includes B.h, and if I first convert B.h into
B.h.pch, and A.h into A.h.pch, then when parsing main.c which includes
A.h, the identifiers in B.h cannot be recognized. And if the main.c
include both A.h and B.h, the parse will not pass successfully even if I
use #ifdef... in B.h to avoid redefinitions.
Maybe I have to use chainedincludesSource. However, there is few guides
I can get. I don't know how to use it.
Is there anyone who can help? Do you think using
PPCallback::InclusionDirective is a right way in this situation?
Thank you in advance!
Yao Shen
More information about the cfe-commits
mailing list