[clang-tidy] Add a new checker to detect missing comma in initializer list.
authorEtienne Bergeron <etienneb@google.com>
Thu, 31 Mar 2016 18:12:23 +0000 (18:12 +0000)
committerEtienne Bergeron <etienneb@google.com>
Thu, 31 Mar 2016 18:12:23 +0000 (18:12 +0000)
commit3e4adf17625595d9425fb8109126af22475f54c0
tree6f56b1b5347bb7ffadff6b59fc0371e29ad42ed2
parent4badd6aaf30859ce9b89960d8cae2b9ecd1dacca
[clang-tidy] Add a new checker to detect missing comma in initializer list.

Summary:
This checker is able to detect missing comma in
an array of string literals.

```
  const char* A[] = {
    "abc",
    "def"   // missing comma (no compiler warnings)
    "ghi",
  };
```

The ratio of false-positive is reduced by restricting the
size of the array considered and the ratio of missing
comma.

To validate the quantity of false positive, the checker
was tried over LLVM and chromium code and detected these
cases:

[[ http://reviews.llvm.org/D18454 | http://reviews.llvm.org/D18454 ]]
[[https://codereview.chromium.org/1807753002/ | https://codereview.chromium.org/1807753002/]]
[[https://codereview.chromium.org/1826193002/ | https://codereview.chromium.org/1826193002/]]
[[https://codereview.chromium.org/1805713002/ | https://codereview.chromium.org/1805713002/]]

Reviewers: alexfh

Subscribers: LegalizeAdulthood, szdominik, xazax.hun, cfe-commits

Differential Revision: http://reviews.llvm.org/D18457

llvm-svn: 265033
clang-tools-extra/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/clang-tidy/misc/SuspiciousMissingCommaCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/misc/SuspiciousMissingCommaCheck.h [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/misc-suspicious-missing-comma.cpp [new file with mode: 0644]