[cfe-dev] Precompiled headers with libclang

Douglas Gregor dgregor at apple.com
Tue Apr 3 07:29:51 PDT 2012

On Apr 3, 2012, at 6:25 AM, Abhanshu Sharma wrote:

> I have actually set it 'on' already. But by running strace, I found that libclang is still accessing quite a few headers (Although Number of headers accessed reduced a bit). 
> Is this expected? 

You'll see libclang stat'ing all of the headers in the precompiled preamble, because it needs to determine whether they have changed.

> Or libclang is just expected to access preamble file? Is there any case where it can discard contents of preamble file.

If the underlying headers change, or the #includes of the source file change, the precompiled preamble will be thrown out and regenerated.

	- Doug

> On Tue, Apr 3, 2012 at 6:49 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Sent from my iPhone
> On Apr 3, 2012, at 4:00 AM, Abhanshu Sharma <abhanshu1 at gmail.com> wrote:
> > Hi cfe-devs,
> >
> > I have a particular scenario where there is a single changing source C++ file which depends on large number of header files (which are constant). What I want libclang to do is to just reparse this source file and extract rest of information from a single precompiled header file in lieu of those header files.
> >
> > I am able to serialize and deserialize a Translation unit. But I am not able to serialize a TU and use it as a library.  Does .pch files work with libclang?
> >
> > For our needs, we have 1 changing C++ source file and rest everything is constant in very large codebase. And we want to repeatedly invoke code complete or error checks on these. Is this setup possible with libclang?
> Just turn on precompiled preambles in libclang. After the first reparse, libclang will automatically create a PCH file for the headers at the top of your source file and use it for subsequent reparses and code completions.
> > --
> > Regards,
> > Abhanshu
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> -- 
> Warm Regards,
> Abhanshu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120403/729d13d7/attachment.html>

More information about the cfe-dev mailing list