|
| 1 | +# Use of `clang-tidy` on 3C |
| 2 | + |
| 3 | +We're starting to use `clang-tidy` to automatically enforce some of the LLVM |
| 4 | +style guidelines in our code. The main configuration is in |
| 5 | +`clang/lib/3C/.clang-tidy`. |
| 6 | + |
| 7 | +We're currently using version 11.0.0 due to bugs in older versions, so if you |
| 8 | +want to verify that our code is compliant with `clang-tidy`, you'll need to get |
| 9 | +a copy of that version. If it isn't available from your OS distribution, you may |
| 10 | +need to build it from source. This repository is currently based on a |
| 11 | +pre-release of LLVM 9.0.0, so you can't use its version of `clang-tidy`. |
| 12 | +However, Microsoft plans to upgrade it to LLVM 11.0.0 soon, at which point |
| 13 | +you'll have the option to use `clang-tidy` built from this repository. |
| 14 | + |
| 15 | +This file maintains a list of `clang-tidy` problems we've encountered that led |
| 16 | +to warnings we needed to suppress, so those suppressions can refer to the |
| 17 | +corresponding entries in this file. |
| 18 | + |
| 19 | +## `_3C` name prefix |
| 20 | + |
| 21 | +We use `3C` in the names of some program elements. Since an identifier cannot |
| 22 | +begin with a digit, for names that would begin with `3C`, we decided that the |
| 23 | +least evil is to prepend an underscore so the name begins with `_3C`. (A leading |
| 24 | +underscore sometimes suggests that a program element is "private" or "special", |
| 25 | +which is not the case here; this may be misleading.) One alternative we |
| 26 | +considered was to use `ThreeC` at the beginning of a name, but that would be |
| 27 | +inconsistent and would make it more work to search for all occurrences of either |
| 28 | +`3C` or `ThreeC`. And we thought the alternative of using `ThreeC` everywhere |
| 29 | +was just too clunky. |
| 30 | + |
| 31 | +Unfortunately, the current implementation of the [LLVM naming |
| 32 | +guideline](https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly) |
| 33 | +in the `readability-identifier-naming` check does not allow names to begin with |
| 34 | +underscores; in fact, it proposes to remove the underscores, leaving invalid |
| 35 | +identifiers that break compilation. There's no indication that the guideline has |
| 36 | +contemplated our scenario, and we don't know whether its maintainers would allow |
| 37 | +our scenario if they knew about it; we've filed [a |
| 38 | +bug](https://bugs.llvm.org/show_bug.cgi?id=48230) to ask. |
0 commit comments