I have integrated clang-tidy into a text-editor project, re-running clang-tidy as the user types. It works, but it can be slow to reparse the entire file and #includes after every edit.
I've also experimented using libclang's precompiled preambles and clang_reparseTranslationUnit(). This works great for reparse performance, but I'm having trouble figuring out how to incorporate the clang-tidy checkers.
I would appreciate any advice on speeding up clang-tidy so that repeatedly reparsing a file doesn't need to reparse all the #included headers.
I have managed to integrate clang-tidy as a plugin in libclang. I
haven’t exposed the entire command-line options, but it is working for
my purposes.
How are you planning on integrating the two?
expose clang-tidy via libclang (or similar); plugin sounds like a good idea, but we also will want a stable (for the future) interface for editors to rely on
I have managed to integrate clang-tidy as a plugin in libclang. I
haven't exposed the entire command-line options, but it is working for
my purposes.
That's awesome!
Can you share the extra plumbing needed in order to load clang-tidy as a
plugin?
For loading the Clang plugin in libclang I presume you also needed a similar
patch like ⚙ D15729 Load compiler plugins in ASTUnit, too, right? Care to help out reviewing +
assuring this makes it into Clang proper?
Can you share the extra plumbing needed in order to load clang-tidy as a
plugin?
For loading the Clang plugin in libclang I presume you also needed a similar
patch like ⚙ D15729 Load compiler plugins in ASTUnit, too, right? Care to help out reviewing +
assuring this makes it into Clang proper?
Since the plugin mechanism doesn't work with windows .dlls, I had to statically link the plugin, so that patch wasn't necessary for me.
I'm not ready to share a patch, as I'm still working out the kinks of the plugin itself. There were lifetime issues regarding the ClangTidyContext, so I had to change the ClangTidyASTConsumer to own the Context since the PluginASTAction is deleted right after creating the consumer. These changes break the clang-tidy tool unfortunately.