[cfe-dev] Using precompiled headers with libtooling?
Loïc Joly via cfe-dev
cfe-dev at lists.llvm.org
Mon Aug 21 11:51:24 PDT 2017
Hello,
I've made some progress in that direction, but I'm not done yet, and I have some hard time putting it all together, so I'm thinking I may be missing something obvious. So I'd like to describe what I've done so far:
* I gave up using a ClangTool to run the preprocessing step, it just did not work. Instead, I'm creating a CompilerInvocation and pass it to a custom FrontendActionFactory that returns a GeneratePCHAction.
* This sort of works (assuming I pass to the CompilerInvocation all the arguments equivalent to the ones I pass to the ClangTool that I use later). But then, when I have any error in the PCH code, the PCH is not saved on disk (for what I do, I really don't mind having incomplete results, so I'd like to save it anyway)
* So I created a new action that inherits from GeneratePCHAction but in CreateASTConsumer has the same code as its base class, but uses true instead of false for the argument AllowASTWithErrors of the PCHGenerator constructor. But still, the PCH file does not get generated in case of errors.
Do you think I'm going in the right direction? Do you have any idea what I should do to achieve my goal?
I've got another question: Many tooling function have a shared_ptr<PCHContainerOperations> argument. Does it mean I could use a PCH in memory without ever saving it to the disk, or is if just to be used for modules, as the documentation seems to imply? Do you have any hint about how this can be used?
Thank you!
---
Loïc Joly
De : cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] De la part de Loïc Joly via cfe-dev
Envoyé : lundi 7 août 2017 20:39
À : cfe-dev at lists.llvm.org
Objet : [cfe-dev] Using precompiled headers with libtooling?
Hello,
We are using clang libtooling, and we think about enabling precompiled headers to speed-up our processing, but I've not found any document about that, so I have a few questions:
* If we do so, will the content of the pch be visited with a RecursiveASTVisitor? With an ast matcher?
* Will code location inside the PCH refer to the files that generated the pch?
* Are there any other caveat?
* Is there a tool to generate the pch with an interface similar to ClangTool, or should I just spawn a sub process the create the pch before starting the tool?
Thank you for your help,
---
Loïc Joly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170821/09b38a6d/attachment.html>
More information about the cfe-dev
mailing list