[PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

Kirill Bobyrev via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 08:06:41 PDT 2016


omtcyfz created this revision.
omtcyfz added reviewers: alexfh, aaron.ballman, ioeric.
omtcyfz added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz, nemanjai.

C++ Core Guidelines Section "Expressions and statements" Suggestion 10 proposes to split declarations with multiple names into multiple single declarations. See the following example.

Example, bad.

```
std::vector<int> velocities(10, 0), numbers(other_numbers),
                          inputs(input.begin(), input.end());
```

Example, good.

```
std::vector<int> velocities(10, 0);
std::vector<int> numbers(other_numbers);
std::vector<int> inputs(input.begin(), input.end());
```

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#a-nameres-name-oneaes10-declare-one-name-only-per-declaration

https://reviews.llvm.org/D25024

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25024.72830.patch
Type: text/x-patch
Size: 7491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160928/d482989c/attachment.bin>


More information about the cfe-commits mailing list