3 ms·
What's the difference between clang-format and clang-tidy? Do they have different configuration options? I'm only using clang-format so far.
by lrsjng 8y ago
What's the difference between clang-format and clang-tidy? Do they have different configuration options? I'm only using clang-format so far.
- danpat 8y agoclang-format kinda does what it says - parses your code, then indents and spaces it according to the rules. It doesn't try to understand code intent, it just looks at syntax. clang-tidy does some deeper inspection and can be used to flag things that are "bad practice", not just "bad formatting". There's a big list of checks here: https://clang.llvm.org/extra/clang-tidy/checks/list.html https://clang.llvm.org/extra/clang-tidy/checks/list.html At a minimum, I like to enable all the `bugprone-*` tidy rules, they just seem sensible to turn on. e.g. https://clang.llvm.org/extra/clang-tidy/checks/bugprone-string-constructor.html https://clang.llvm.org/extra/clang-tidy/checks/bugprone-stri... You're able to run `clang-tidy -fix` to automate fixing of many of the things it will flag.