Skip to content

clang-tidy: Add check modernize-use-auto

Add and apply clang-tidy check modernize-use-auto.

This check enforces the rule of declaring variables that are easily deduced from context with auto, instead of using the full type name. Not only does this improve readability, by making the code shorter, but also facilitates future code refactoring.

This check is configurable. Therefore, I divided this MR in multiple commits to show the effect of the multiple configurations:

  • Replace iterators with auto. Always enabled.
  • Replace declaration and allocation of pointers. The pointer's type is already stated in the new declaration.
  • Variables initialized with casts. The implicit variable's type is the same as the cast's type.

Please state your opinion on the multiple configurations.

TO DO:

  • Manually convert iterators whose declaration is separated from value assignment [egrep -rn --include="*.cc" --include="*.h" "::(const_)?iterator" ]
Edited by Eduardo Almeida

Merge request reports