.clang-tidy 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. ---
  5. # Get colors when outputting through `bazel build --config=clang-tidy`.
  6. UseColor: true
  7. # This is necessary for `--config=clang-tidy` to catch errors.
  8. WarningsAsErrors: '*'
  9. # - bugprone-exception-escape finds issues like out-of-memory in main(). We
  10. # don't use exceptions, so it's unlikely to find real issues.
  11. # - bugprone-macro-parentheses has false positives in places such as using an
  12. # argument to declare a name, which cannot have parentheses. For our limited
  13. # use of macros, this is a common conflict.
  14. # - bugprone-switch-missing-default-case has false positives for `enum_base.h`.
  15. # Clang's built-in switch warnings cover most of our risk of bugs here.
  16. # - bugprone-unchecked-optional-access in clang-tidy 16 has false positives on
  17. # code like:
  18. # while (auto name_ref = insts().Get(inst_id).TryAs<SemIR::NameRef>()) {
  19. # inst_id = name_ref->value_id;
  20. # ^ unchecked access to optional value
  21. # }
  22. # - google-readability-function-size overlaps with readability-function-size.
  23. # - modernize-use-designated-initializers is disabled because it fires on
  24. # creation of SemIR typed insts, for which we do not currently want to use
  25. # designated initialization.
  26. # - modernize-use-nodiscard is disabled because it only fixes const methods,
  27. # not non-const, which yields distracting results on accessors.
  28. # - performance-unnecessary-value-param is disabled because it duplicate
  29. # modernize-pass-by-value.
  30. Checks:
  31. -*, bugprone-*, -bugprone-branch-clone, -bugprone-easily-swappable-parameters,
  32. -bugprone-exception-escape, -bugprone-macro-parentheses,
  33. -bugprone-narrowing-conversions, -bugprone-switch-missing-default-case,
  34. -bugprone-unchecked-optional-access, google-*,
  35. -google-readability-function-size, -google-readability-todo,
  36. misc-definitions-in-headers, misc-misplaced-const, misc-redundant-expression,
  37. misc-static-assert, misc-unconventional-assign-operator,
  38. misc-uniqueptr-reset-release, misc-unused-*, modernize-*,
  39. -modernize-avoid-c-arrays, -modernize-return-braced-init-list,
  40. -modernize-use-default-member-init, -modernize-use-designated-initializers,
  41. -modernize-use-emplace, -modernize-use-nodiscard, performance-*,
  42. -performance-unnecessary-value-param, readability-*,
  43. -readability-convert-member-functions-to-static,
  44. -readability-function-cognitive-complexity, -readability-else-after-return,
  45. -readability-identifier-length, -readability-implicit-bool-conversion,
  46. -readability-magic-numbers, -readability-make-member-function-const,
  47. -readability-static-definition-in-anonymous-namespace,
  48. -readability-suspicious-call-argument, -readability-use-anyofallof
  49. CheckOptions:
  50. - { key: readability-identifier-naming.ClassCase, value: CamelCase }
  51. - { key: readability-identifier-naming.ClassConstantCase, value: CamelCase }
  52. - {
  53. key: readability-identifier-naming.ConstexprVariableCase,
  54. value: CamelCase,
  55. }
  56. - { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
  57. - { key: readability-identifier-naming.StructCase, value: CamelCase }
  58. - {
  59. key: readability-identifier-naming.TemplateParameterCase,
  60. value: CamelCase,
  61. }
  62. - { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
  63. - { key: readability-identifier-naming.TypedefCase, value: CamelCase }
  64. - { key: readability-identifier-naming.UnionCase, value: CamelCase }
  65. - { key: readability-identifier-naming.VariableCase, value: lower_case }
  66. - { key: readability-identifier-naming.ParameterCase, value: lower_case }
  67. - { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
  68. - {
  69. key: readability-identifier-naming.MethodIgnoredRegexp,
  70. value: '^classof$',
  71. }
  72. - {
  73. # This erroneously fires in C++20 mode with LLVM 16 clang-tidy, due to:
  74. # https://github.com/llvm/llvm-project/issues/46097
  75. key: readability-identifier-naming.TemplateParameterIgnoredRegexp,
  76. value: '^expr-type$',
  77. }