|
| 1 | +--- |
| 2 | +# Google C++ Style Guide enforcement. |
| 3 | +# |
| 4 | +# `clang-format` (via `.clang-format`) handles formatting; this file handles |
| 5 | +# everything `clang-format` cannot see — primarily identifier naming. |
| 6 | +# |
| 7 | +# Usage: |
| 8 | +# clang-tidy -p build/ --quiet <file> (needs `compile_commands.json`) |
| 9 | +# |
| 10 | +# The project's scikit-build config sets `CMAKE_EXPORT_COMPILE_COMMANDS=ON`, |
| 11 | +# so `pip install -e .[dev]` produces `build*/compile_commands.json`. |
| 12 | +# |
| 13 | +# Subdirectories may ship their own `.clang-tidy` with |
| 14 | +# `InheritParentConfig: true` to override specific rules (e.g. |
| 15 | +# `src/ascend/custom/.clang-tidy` relaxes `FunctionCase` for `extern "C"` |
| 16 | +# `AscendC` kernel entries whose symbol names are dictated by |
| 17 | +# `ascendc_add_operator(OP_NAME …)`). |
| 18 | + |
| 19 | +Checks: > |
| 20 | + readability-identifier-naming, |
| 21 | + google-explicit-constructor, |
| 22 | + google-readability-braces-around-statements, |
| 23 | + google-readability-casting, |
| 24 | + modernize-use-nullptr, |
| 25 | + modernize-use-override |
| 26 | +
|
| 27 | +# Only naming violations fail the lint — the rest are advisory while the |
| 28 | +# project ramps up on `clang-tidy`. |
| 29 | +WarningsAsErrors: 'readability-identifier-naming.*' |
| 30 | + |
| 31 | +HeaderFilterRegex: '^(src|tests)/.*\.(h|hpp|cuh)$' |
| 32 | + |
| 33 | +CheckOptions: |
| 34 | + # ---------- Types ---------- |
| 35 | + - {key: readability-identifier-naming.ClassCase, value: CamelCase} |
| 36 | + - {key: readability-identifier-naming.StructCase, value: CamelCase} |
| 37 | + - {key: readability-identifier-naming.UnionCase, value: CamelCase} |
| 38 | + - {key: readability-identifier-naming.EnumCase, value: CamelCase} |
| 39 | + - {key: readability-identifier-naming.TypeAliasCase, value: CamelCase} |
| 40 | + - {key: readability-identifier-naming.TypedefCase, value: CamelCase} |
| 41 | + - {key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase} |
| 42 | + |
| 43 | + # ---------- Enumerators / constants: `k` + PascalCase ---------- |
| 44 | + - {key: readability-identifier-naming.EnumConstantCase, value: CamelCase} |
| 45 | + - {key: readability-identifier-naming.EnumConstantPrefix, value: 'k'} |
| 46 | + - {key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase} |
| 47 | + - {key: readability-identifier-naming.ConstexprVariablePrefix, value: 'k'} |
| 48 | + - {key: readability-identifier-naming.GlobalConstantCase, value: CamelCase} |
| 49 | + - {key: readability-identifier-naming.GlobalConstantPrefix, value: 'k'} |
| 50 | + - {key: readability-identifier-naming.StaticConstantCase, value: CamelCase} |
| 51 | + - {key: readability-identifier-naming.StaticConstantPrefix, value: 'k'} |
| 52 | + |
| 53 | + # ---------- Functions / methods: PascalCase ---------- |
| 54 | + - {key: readability-identifier-naming.FunctionCase, value: CamelCase} |
| 55 | + - {key: readability-identifier-naming.MethodCase, value: CamelCase} |
| 56 | + |
| 57 | + # ---------- Variables / parameters: snake_case ---------- |
| 58 | + - {key: readability-identifier-naming.VariableCase, value: lower_case} |
| 59 | + - {key: readability-identifier-naming.ParameterCase, value: lower_case} |
| 60 | + - {key: readability-identifier-naming.LocalVariableCase, value: lower_case} |
| 61 | + |
| 62 | + # ---------- Class data members: snake_case with trailing `_` ---------- |
| 63 | + - {key: readability-identifier-naming.PrivateMemberCase, value: lower_case} |
| 64 | + - {key: readability-identifier-naming.PrivateMemberSuffix, value: '_'} |
| 65 | + - {key: readability-identifier-naming.ProtectedMemberCase, value: lower_case} |
| 66 | + - {key: readability-identifier-naming.ProtectedMemberSuffix, value: '_'} |
| 67 | + - {key: readability-identifier-naming.PublicMemberCase, value: lower_case} |
| 68 | + |
| 69 | + # ---------- Macros: UPPER_CASE ---------- |
| 70 | + - {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE} |
| 71 | + # Include guards end in a trailing `_` (e.g. `INFINI_OPS_FOO_H_`), which |
| 72 | + # the default `UPPER_CASE` style rejects — skip them by regex. |
| 73 | + - {key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: '^INFINI_OPS_.*_H_$'} |
| 74 | + |
| 75 | + # ---------- Namespaces: lower_case ---------- |
| 76 | + - {key: readability-identifier-naming.NamespaceCase, value: lower_case} |
| 77 | + |
| 78 | + # ---------- Exemptions ---------- |
| 79 | + # Type-trait variables (`IsFP16`, `IsBFloat16`, `HasKey`, …) mirror |
| 80 | + # `std::is_*_v<>` naming — `PascalCase` without `k` prefix. |
| 81 | + - {key: readability-identifier-naming.ConstexprVariableIgnoredRegexp, value: '^(Is|Has|Can)[A-Z].*'} |
0 commit comments