[PATCH] D45444: [clang-tidy] implement new check for const-correctness

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 7 15:17:38 PDT 2018


JonasToth added a comment.

For reference, here is the output for llvm/lib.
F6896569: const_correctness_2_llvm_lib_references <https://reviews.llvm.org/F6896569>

F6896567: const_correctness_2_llvm_lib_values_pointers <https://reviews.llvm.org/F6896567>

Things i noticed:

- lambdas are warned as potential const, i think they should be excluded for the values
- for-loops that initialize two values (usually the start and end-iterator) are correctly diagnosed, but the diagnosis might be misleading. Especially because there is no way to have a const-iterator initialized together with the changing iterator.

`for (auto begin = vec.begin(), end = vec.end(); ...)`

- there seems to be a false positive with array-to-pointer decay. ExprMutAnalyzer does think of it, but maybe there is a bug in it.
- pointer diagnostics don't seem to worker (pointer-as-value). The test-case does work, This must be analyzed further
- there was a bug in the `check` method, where `AnalyzeValues == 0` did imply no analysis is done.

Given the volume of diagnostics for the value-case i did not investigate many cases manually. I think it makes sense to strive for code-transformation and check if the code still compiles.

References on the other hand seem to function correctly, and most references are single-var-decls, too. That means code transformation is very simple and therefor an easy target to check functionality.
References and values are in general treated the same, so it might give a hint about the performance for values.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444





More information about the cfe-commits mailing list