[cfe-dev] Change multiple locations for single clang-tidy check

Alexander Kornienko alexfh at google.com
Wed Jun 4 06:11:00 PDT 2014


On Wed, Jun 4, 2014 at 3:30 AM, Daniel Dilts <diltsman at gmail.com> wrote:

> Is there a way to modify multiple locations if a given check finds an
> issue?  My use case is I am checking for class naming conventions.
>
> If the check finds a declaration I can figure out how to modify the name
> at the declaration, but I want to also change all usages at the same time.
>

It's possible to supply several FixItHints, and they can be in any source
files known to SourceManager. I didn't check, but this should work, and if
it doesn't, I'll fix it.

But you're going to face another problem as well: usages of a class or its
members may be spread over many translation units, and clang-tidy's support
of the multiple-TU use-case is rudimentary at the moment. While you can run
the clang-tidy binary on several translation units, and it will even
deduplicate error reports by code location, there are still many things to
do in this land:
  * We'll need a way to run over all translation units in the compilations
database, so that clang-tidy can be sure it sees all the code, and that the
changes it makes are complete.
  * We'll need a way to separate analysis from the actual application of
generated fixes, so that one could run several clang-tidy processes in
parallel to speed up the refactoring.
  * We'd also need not only to deduplicate changes, but also check all the
changes for mutual compatibility - this is not specific to multi-TU
use-case, but with multiple TUs chances to get incompatible changes are
higher.

I'm probably missing something else that would be important for the
multiple-TU case.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140604/5f77d4ce/attachment.html>


More information about the cfe-dev mailing list