.clang-tidy 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. Checks:
  10. # We turn on all of a few categories by default.
  11. - '-*'
  12. - 'bugprone-*'
  13. - 'google-*'
  14. - 'misc-*'
  15. - 'modernize-*'
  16. - 'performance-*'
  17. - 'readability-*'
  18. # Disabled due to the implied style choices.
  19. - '-misc-const-correctness'
  20. - '-misc-include-cleaner'
  21. - '-misc-use-anonymous-namespace'
  22. - '-modernize-return-braced-init-list'
  23. - '-modernize-use-default-member-init'
  24. - '-modernize-use-integer-sign-comparison'
  25. - '-modernize-use-emplace'
  26. - '-readability-avoid-nested-conditional-operator'
  27. - '-readability-convert-member-functions-to-static'
  28. - '-readability-else-after-return'
  29. - '-readability-identifier-length'
  30. - '-readability-implicit-bool-conversion'
  31. - '-readability-make-member-function-const'
  32. - '-readability-math-missing-parentheses'
  33. - '-readability-static-definition-in-anonymous-namespace'
  34. - '-readability-use-anyofallof'
  35. # Warns when we have multiple empty cases in switches, which we do for comment
  36. # reasons.
  37. - '-bugprone-branch-clone'
  38. # Frequently warns on multiple parameters of the same type.
  39. - '-bugprone-easily-swappable-parameters'
  40. # Finds issues like out-of-memory in main(). We don't use exceptions, so it's
  41. # unlikely to find real issues.
  42. - '-bugprone-exception-escape'
  43. # Has false positives in places such as using an argument to declare a name,
  44. # which cannot have parentheses. For our limited use of macros, this is a
  45. # common conflict.
  46. - '-bugprone-macro-parentheses'
  47. # Conflicts with integer type C++ style.
  48. - '-bugprone-narrowing-conversions'
  49. # Has false positives for `enum_base.h`. Clang's built-in switch warnings
  50. # cover most of our risk of bugs here.
  51. - '-bugprone-switch-missing-default-case'
  52. # In clang-tidy 16, has false positives on code like:
  53. # while (auto name_ref = insts().Get(inst_id).TryAs<SemIR::NameRef>()) {
  54. # inst_id = name_ref->value_id;
  55. # ^ unchecked access to optional value
  56. # }
  57. - '-bugprone-unchecked-optional-access'
  58. # Overlaps with `readability-function-size`.
  59. - '-google-readability-function-size'
  60. # Suggests usernames on TODOs, which we don't want.
  61. - '-google-readability-todo'
  62. # Extremely slow. TODO: Re-enable once
  63. # https://github.com/llvm/llvm-project/issues/128797 is fixed.
  64. - '-misc-confusable-identifiers'
  65. # Overlaps with `-Wno-missing-prototypes`.
  66. - '-misc-use-internal-linkage'
  67. # Suggests `std::array`, which we could migrate to, but conflicts with the
  68. # status quo.
  69. - '-modernize-avoid-c-arrays'
  70. # Warns on creation of SemIR typed insts, for which we do not currently want
  71. # to use designated initialization.
  72. - '-modernize-use-designated-initializers'
  73. # Only fixes const methods, not non-const, which yields distracting results on
  74. # accessors.
  75. - '-modernize-use-nodiscard'
  76. # We aren't using the ranges library due to performance concerns.
  77. - '-modernize-use-ranges'
  78. # Low value compared to the engineering cost.
  79. - '-performance-enum-size'
  80. # Duplicates `modernize-pass-by-value`.
  81. - '-performance-unnecessary-value-param'
  82. # Warns on enums which use the `LastValue = Value` pattern if all the other
  83. # discriminants aren't given an explicit value.
  84. - '-readability-enum-initial-value'
  85. # Warns too frequently.
  86. - '-readability-function-cognitive-complexity'
  87. # Warns in reasonably documented situations.
  88. - '-readability-magic-numbers'
  89. # Warns on `= {}` which is also used to indicate which fields do not need to
  90. # be explicitly initialized in aggregate initialization.
  91. - '-readability-redundant-member-init'
  92. # Warns when callers use similar names as different parameters.
  93. - '-readability-suspicious-call-argument'
  94. CheckOptions:
  95. # Don't warn on structs; done by ignoring when there are only public members.
  96. - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
  97. value: true
  98. # CamelCase names.
  99. - key: readability-identifier-naming.ClassCase
  100. value: CamelCase
  101. - key: readability-identifier-naming.ClassConstantCase
  102. value: CamelCase
  103. - key: readability-identifier-naming.ConstexprVariableCase
  104. value: CamelCase
  105. - key: readability-identifier-naming.NamespaceCase
  106. value: CamelCase
  107. - key: readability-identifier-naming.StructCase
  108. value: CamelCase
  109. - key: readability-identifier-naming.TemplateParameterCase
  110. value: CamelCase
  111. - key: readability-identifier-naming.TypeAliasCase
  112. value: CamelCase
  113. - key: readability-identifier-naming.TypedefCase
  114. value: CamelCase
  115. - key: readability-identifier-naming.UnionCase
  116. value: CamelCase
  117. # lower_case names.
  118. - key: readability-identifier-naming.ClassMemberCase
  119. value: lower_case
  120. - key: readability-identifier-naming.ParameterCase
  121. value: lower_case
  122. - key: readability-identifier-naming.VariableCase
  123. value: lower_case
  124. # TODO: This is for explorer's use of LLVM casting support, so we should be
  125. # able to remove it once explorer is deleted.
  126. - key: readability-identifier-naming.MethodIgnoredRegexp
  127. value: '^classof$'
  128. # This erroneously fires in C++20 mode with LLVM 16 clang-tidy, due to:
  129. # https://github.com/llvm/llvm-project/issues/46097
  130. - key: readability-identifier-naming.TemplateParameterIgnoredRegexp
  131. value: '^expr-type$'