diff options
author | Jonas Toth <jonas.toth@gmail.com> | 2018-11-12 16:01:39 +0000 |
---|---|---|
committer | Jonas Toth <jonas.toth@gmail.com> | 2018-11-12 16:01:39 +0000 |
commit | 6b3d33e99677aa80fa2a899902323b0e6c7e3762 (patch) | |
tree | c5d634d2bc085fff265a388065e753a34e7f0330 /clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | |
parent | f4cd292ba25d7e286df41475328cd785ff97726f (diff) | |
download | llvm-6b3d33e99677aa80fa2a899902323b0e6c7e3762.zip llvm-6b3d33e99677aa80fa2a899902323b0e6c7e3762.tar.gz llvm-6b3d33e99677aa80fa2a899902323b0e6c7e3762.tar.bz2 |
[clang-tidy] new check: bugprone-too-small-loop-variable
The new checker searches for those for loops which has a loop variable with a "too small" type which means this type can't represent all values which are part of the iteration range.
For example:
```
int main() {
long size = 300000;
for( short int i = 0; i < size; ++i) {}
}
```
The short type leads to infinite loop here because it can't store all values in the `[0..size]` interval. In a real use case, size means a container's size which depends on the user input. Which means for small amount of objects the algorithm works, but with a larger user input the software will freeze.
The idea of the checker comes from the LibreOffice project, where the same check was implemented as a clang compiler plugin, called `LoopVarTooSmall` (LLVM licensed).
The idea is the same behind this check, but the code is different because of the different framework.
Patch by ztamas.
Reviewers: alexfh, hokein, aaron.ballman, JonasToth, xazax.hun, whisperity
Reviewed By: JonasToth, whisperity
Differential Revision: https://reviews.llvm.org/D53974
llvm-svn: 346665
Diffstat (limited to 'clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
0 files changed, 0 insertions, 0 deletions