summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to ↵Adam Balogh2019-05-071-2/+9
| | | | | | | | | | | | structures) Accidentally taking the size of a struct-pointer type or a value of this type is more common than explicitly using the & operator for the value. This patch extends the check to include these cases. Differential Revision: https://reviews.llvm.org/D61260 llvm-svn: 360114
* [clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse ↵Adam Balogh2019-05-061-2/+55
| | | | | | | | | | | | | | | in pointer arithmetic Some programmers tend to forget that subtracting two pointers results in the difference between them in number of elements of the pointee type instead of bytes. This leads to codes such as `size_t size = (p - q) / sizeof(int)` where `p` and `q` are of type `int*`. Or similarily, `if (p - q < buffer_size * sizeof(int)) { ... }`. This patch extends `bugprone-sizeof-expression` to detect such cases. Differential Revision: https://reviews.llvm.org/D61422 llvm-svn: 360032
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-14/+14
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* [clang-tidy] Check for sizeof that call functionsHaojian Wu2018-04-031-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A common mistake that I have found in our codebase is calling a function to get an integer or enum that represents the type such as: ``` int numBytes = numElements * sizeof(x.GetType()); ``` So this extends the `sizeof` check to check for these cases. There is also a `WarnOnSizeOfCall` option so it can be disabled. Patch by Paul Fultz II! Reviewers: hokein, alexfh, aaron.ballman, ilya-biryukov Reviewed By: alexfh Subscribers: lebedev.ri, xazax.hun, jkorous-apple, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D44231 llvm-svn: 329073
* [clang-tidy] rename_check.py misc-sizeof-expression bugprone-sizeof-expressionAlexander Kornienko2018-03-151-0/+265
llvm-svn: 327607
OpenPOWER on IntegriCloud