Reputation: 9703
In particular, I'm using Qt; our codebase is still littered with old foreach
macros, like foreach (T foo, bar) { ... }
. I'd like to turn that to for (T foo : bar) { ... }
. Is there a way to write a clang-tidy rule to do this?
Upvotes: 1
Views: 803
Reputation: 2663
Yes, it's definitely possible. Clang-tidy is open source so nothing stops you from modifying the code or writing your own checks.
The modernize-loop-convert check does something very similar to your use case so it's possibly a good start. (source)
Clang-tidy even has official documentation on writing new checks.
Upvotes: 2