[clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConve...
authorStephen Concannon <stephen.concannon@gmail.com>
Wed, 12 May 2021 18:25:22 +0000 (20:25 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Wed, 12 May 2021 18:51:25 +0000 (20:51 +0200)
commit211761332e4381c37edd91be7c59fc048014ff4e
tree4022e904dbf763b5c99f15b656c0ca1bd8a99902
parented9e1a7dcc2eceb4596a5f2ede7daabcb1fdf4ab
[clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConversionsCheck.

Within clang-tidy's NarrowingConversionsCheck.
* Allow opt-out of some common occurring patterns, such as:
  - Implicit casts between types of equivalent bit widths.
  - Implicit casts occurring from the return of a ::size() method.
  - Implicit casts on size_type and difference_type.
* Allow opt-in of errors within template instantiations.

This will help projects adopt these guidelines iteratively.
Developed in conjunction with Yitzhak Mandelbaum (ymandel).

Patch by Stephen Concannon!

Differential Revision: https://reviews.llvm.org/D99543
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-intemplates-option.cpp [new file with mode: 0644]