summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* Adding a checker (cert-dcl50-cpp) that detects the definition of a C-style ↵Aaron Ballman2015-10-054-0/+76
| | | | | | variadic function in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function llvm-svn: 249343
* Use better mocks in modernize-make-unique, and fix matcher.Angel Garcia Gomez2015-10-051-3/+11
| | | | | | | | | | | | Summary: Add the second template argument to the unique_ptr mock, and update the matcher so that it only matches against cases where the second argument is the default. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13433 llvm-svn: 249305
* Document a bug in loop-convert and fix one of its subcases.Angel Garcia Gomez2015-10-051-2/+15
| | | | | | | | | | | | Summary: Now that we prioritize copying trivial types over using const-references where possible, I found some cases where, after the transformation, the loop was using the address of the local copy instead of the original object. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13431 llvm-svn: 249300
* Fix bug in modernize-use-nullptr.Angel Garcia Gomez2015-10-051-7/+24
| | | | | | | | | | | | | | | | | Summary: https://llvm.org/bugs/show_bug.cgi?id=24960 modernize-use-nullptr would hit an assertion in some cases involving macros and initializer lists, due to finding a node with more than one parent (the two forms of the initializer list). However, this doesn't mean that the replacement is incorrect, so instead of just rejecting this case I tried to find a way to make it work. Looking at the semantic form of the InitListExpr made sense to me (looking at both forms results in false negatives) but I am not sure of the things that we can miss by skipping the syntactic form. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13246 llvm-svn: 249291
* SourceRanges are small and trivially copyable, don't them by reference. NFCCraig Topper2015-10-041-2/+2
| | | | llvm-svn: 249258
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-1/+1
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Taking a stab at fixing failing build bots that use make. Unfortunately, the ↵Aaron Ballman2015-10-021-4/+3
| | | | | | | | build logs do not point to much useful information for tracking this down, such as: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31782/steps/compile/logs/stdio llvm-svn: 249136
* Hopefully rectifying a build bot issue with:Aaron Ballman2015-10-022-1/+3
| | | | | | | | http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux/builds/2833/steps/build_llvmclang/logs/stdio Also, drive-by comment fix in a makefile. llvm-svn: 249133
* Adding a new clang-tidy module to house CERT-specific checkers, and map ↵Aaron Ballman2015-10-028-3/+94
| | | | | | existing checkers to CERT secure coding rules and recommendations for both C (https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard) and C++ (https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637). llvm-svn: 249130
* Handle trailing underscores on modernize-loop-convert variable namer.Angel Garcia Gomez2015-10-021-0/+11
| | | | | | | | | | | | Summary: https://llvm.org/bugs/show_bug.cgi?id=24961. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13381 llvm-svn: 249127
* Prevent loop-convert from leaving empty lines after removing an alias ↵Angel Garcia Gomez2015-10-012-1/+30
| | | | | | | | | | | | | | declaration. Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=17716. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13342 llvm-svn: 249006
* [clang-tidy] fix add_new_check.pyAlexander Kornienko2015-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this check, I would get the following error: Updating ./misc/CMakeLists.txt... Creating ./misc/NoReinterpret_castCheck.h... Creating ./misc/NoReinterpret_castCheck.cpp... Updating ./misc/MiscTidyModule.cpp... Creating ../test/clang-tidy/misc-no-reinterpret_cast.cpp... Creating ../docs/clang-tidy/checks/misc-no-reinterpret_cast.rst... Traceback (most recent call last): File "./add_new_check.py", line 271, in <module> main() File "./add_new_check.py", line 267, in main update_checks_list(module_path) File "./add_new_check.py", line 220, in update_checks_list os.listdir('docs/clang-tidy/checks'))) OSError: [Errno 2] No such file or directory: 'docs/clang-tidy/checks' Patch by Matthias Gehre! Differential revision: http://reviews.llvm.org/D13272 llvm-svn: 248997
* [clang-tidy] Implement FixitHints for identifier references in ↵Alexander Kornienko2015-10-011-14/+116
| | | | | | | | | | | | | | IdentifierNamingCheck This diff requires http://reviews.llvm.org/D13079 to be applied first. I wasn't sure about how to make patch series in Phabricator, and I wanted to keep the two separate for clarity. It looks like that most cases can be supported with this patch. I'm not totally sure about the actual coverage though. I think that the matchers are very generic, but I'm still not totally fluent with the AST. Patch by Beren Minor! Differential revision: http://reviews.llvm.org/D13081 llvm-svn: 248996
* Add support for 'cbegin()' and 'cend()' on modernize-loop-convert.Angel Garcia Gomez2015-10-011-5/+8
| | | | | | | | | | | | | | | Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=22196 . Also add a non-trivially copyable type to fix some tests that were meant to be about using const-refs, but were changed in r248438. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13292 llvm-svn: 248994
* Adding a checker (misc-non-copyable-objects) that detects situations where a ↵Aaron Ballman2015-09-304-2/+132
| | | | | | non-copyable C type is being dereferenced, such as FILE or pthread_mutex_t. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object llvm-svn: 248907
* [clang-tidy] Fix an assertion in the readability-braces-around-statements check.Alexander Kornienko2015-09-301-0/+10
| | | | llvm-svn: 248895
* Adding a checker (misc-new-delete-overloads) that detects mismatched ↵Aaron Ballman2015-09-294-0/+256
| | | | | | overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope llvm-svn: 248791
* Create modernize-make-unique check.Angel Garcia Gomez2015-09-294-0/+153
| | | | | | | | | | | | Summary: create a check that replaces 'std::unique_ptr<type>(new type(args...))' with 'std::make_unique<type>(args...)'. It was on the list of "Ideas for new Tools". It needs to be tested more carefully, but first I wanted to know if you think it is worth the effort. Reviewers: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13166 llvm-svn: 248785
* [clang-tidy] add option to specify build pathGuillaume Papin2015-09-281-4/+11
| | | | | | | | | | | | | | | | | | Summary: compile_commands.json is usually generated in the build directory. Projects like LLVM/Clang enforce out-of-source builds. This option allow allow such projects to work out of the box, without moving the compilation database manually. The naming of the option is similar to the one use by other tools: clang-{check,modernize,query,rename,tidy} -p=<build_path> <...> Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13199 llvm-svn: 248723
* [clang-tidy] Code factorization and cleanup in IdentifierNamingCheckAlexander Kornienko2015-09-282-38/+49
| | | | | | | | | | | | | | | This is to level the ground a little bit, in preparation for the changes in http://reviews.llvm.org/D13081. Code factorization replaces all insertions to NamingCheckFailures map with a unique addUsage function that does the job. There is also no more difference between the declaration and the references to a given identifier, both cases are treated as ranges in the Usage vector. There is also a check to avoid duplicated ranges to be inserted, which sometimes triggered erroneous replacements. References can now also be added before the declaration of the identifier is actually found; this looks to be the case for example when a templated class uses its parameters to specialize its templated base class. Patch by Beren Minor! Differential revision: http://reviews.llvm.org/D13079 llvm-svn: 248700
* [clang-tidy] Updated misc-unused-raii documentation.Alexander Kornienko2015-09-251-22/+2
| | | | llvm-svn: 248594
* Add NamingStyle option to modernize-loop-convert.Angel Garcia Gomez2015-09-245-24/+85
| | | | | | | | | | | | Summary: Add an option to specify wich style must be followed when choosing the new index name. Reviewers: alexfh Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D13052 llvm-svn: 248517
* Remove dangling parenthesis.Angel Garcia Gomez2015-09-241-1/+11
| | | | | | | | | | | | Summary: Remove parenthesis surrounding the new loop index. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D13133 llvm-svn: 248507
* Solve comment on rL248418.Angel Garcia Gomez2015-09-241-3/+1
| | | | | | | | | | | | Summary: Solve comment on rL248418. Reviewers: alexfh Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D13129 llvm-svn: 248489
* Use simpler interface for getting the pointee type for a node.Manuel Klimek2015-09-241-1/+1
| | | | llvm-svn: 248449
* Fix loop-convert for trivially copyable types.Manuel Klimek2015-09-231-31/+32
| | | | | | | | | | | | | | Previously, we would rewrite: void f(const vector<int> &v) { for (size_t i = 0; i < v.size(); ++i) { to for (const auto &elem : v) { Now we rewrite it to: for (auto elem : v) { (and similarly for iterator based loops). llvm-svn: 248438
* Fix loop-convert for const references to containers.Manuel Klimek2015-09-231-0/+6
| | | | | | | | | | | | Previously we would use a non-const loop variable in the range-based loop for: void f(const std::vector<int> &v) { for (size_t i = 0; i < v.size(); ++i) { Now we use const auto&. Note that we'll also want to use a copy at least for simple types. llvm-svn: 248418
* misc-unused-parameter: Ignore lambda static invokers.Daniel Jasper2015-09-221-0/+3
| | | | llvm-svn: 248252
* Refactor LoopConvertCheck.Angel Garcia Gomez2015-09-212-224/+274
| | | | | | | | | | | | Summary: Reorder the code in a more logical and understandable way. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D12797 llvm-svn: 248144
* Pass SourceLocation by value instead of by const reference since its just a ↵Craig Topper2015-09-211-1/+1
| | | | | | 32-bit integer. NFC llvm-svn: 248139
* [clang-tidy] install helper scriptsAlexander Kornienko2015-09-172-0/+21
| | | | | | | | | | | | | | | | | | Scripts are installed in same location as clang-fromat ones, so I think will be good idea to not create dedicated directory. I checked this patch on my own build on RHEL 6. Please check it in if it's OK, because I don't have SVN write access. I think will be good idea to backport this patch to 3.7 release branch. Probably same should be done for configure build. Patch by Eugene Zelenko! Differential revision: http://reviews.llvm.org/D12700 llvm-svn: 247890
* Refactors AST matching code to use the new AST matcher names. This patch ↵Aaron Ballman2015-09-1726-160/+181
| | | | | | correlates to r247885 which performs the AST matcher rename in Clang. llvm-svn: 247886
* [clang-tidy] Ignore spaces in -checks=Alexander Kornienko2015-09-161-1/+1
| | | | llvm-svn: 247812
* [clang-tidy] google-runtime-int: made the matcher more restricting, added a ↵Alexander Kornienko2015-09-161-1/+1
| | | | | | | | test for a false positive This should be NFC. llvm-svn: 247806
* [clang-tidy] Make google-runtime-int configurable.Alexander Kornienko2015-09-162-7/+19
| | | | llvm-svn: 247803
* [clang-tidy] Improve the help text for -dump-config.Alexander Kornienko2015-09-161-2/+4
| | | | llvm-svn: 247792
* [clang-tidy] Update check name in the comment. NFC.Alexander Kornienko2015-09-151-1/+1
| | | | llvm-svn: 247682
* [clang-tidy] misc-sizeof-container: remove fix-it hintsAlexander Kornienko2015-09-141-40/+3
| | | | | | | This turned out to be a rather noisy check, so automated fixes will only do harm. Remove them completely. llvm-svn: 247578
* [clang-tidy] misc-sizeof-container: whitelist std::arrayAlexander Kornienko2015-09-141-1/+1
| | | | llvm-svn: 247559
* Test commit.Marek Kurdej2015-09-141-2/+1
| | | | llvm-svn: 247536
* [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.Alexander Kornienko2015-09-111-0/+1
| | | | | | | It's fine to use sizeof on std::bitset<>, since it doesn't have any external storage, everything's inside. llvm-svn: 247489
* Another patch for modernize-loop-convert.Angel Garcia Gomez2015-09-114-12/+80
| | | | | | | | | | | | | | | | | | Summary: 1. Avoid converting loops that iterate over the size of a container and don't use its elements, as this would result in an unused-result warning. 2. Never capture the elements by value on lambdas, thus avoiding doing unnecessary copies and errors with non-copyable types. 3. The 'const auto &' instead of 'auto &' substitution on const containers now works on arrays and pseudoarrays as well. 4. The error about multiple replacements in the same macro call is now documented in the tests (not solved though). 5. Due to [1], I had to add a dummy usage of the range element (like "(void) *It;" or similars) on the tests that had empty loops. 6. I removed the braces from the CHECK comments. I think that there is no need for them, and they confuse vim. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D12734 llvm-svn: 247399
* [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlAlexander Kornienko2015-09-104-0/+122
| | | | | | | | | | | | | | | | containers. Summary: sizeof(some_std_string) is likely to be an error. This check finds this pattern and suggests using .size() instead. Reviewers: djasper, klimek, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D12759 llvm-svn: 247297
* [clang-tidy] add_new_check.py improvements: add doc file, refer it from .hAlexander Kornienko2015-09-101-13/+59
| | | | | | + some console logging and minor cleanups. llvm-svn: 247282
* [clang-tidy] Add inconsistent declaration parameter name checkAlexander Kornienko2015-09-104-0/+385
| | | | | | | | | | | | | | | | | | | | This is first of series of patches, porting code from my project colobot-lint, as I mentioned recently in cfe-dev mailing list. This patch adds a new check in readability module: readability-inconsistent-declaration-parameter-name. I also added appropriate testcases and documentation. I chose readability module, as it seems it is the best place for it. I think I followed the rules of LLVM coding guideline, but I may have missed something, as I usually use other code formatting style. http://reviews.llvm.org/D12462 Patch by Piotr Dziwinski! llvm-svn: 247261
* [clang-tidy] Fix PR22785.Alexander Kornienko2015-09-091-5/+10
| | | | | | | | | | | Fix http://llvm.org/PR22785. Bug 22785 - readability-braces-around-statements doesn't work well with macros. http://reviews.llvm.org/D12729 Patch by Marek Kurdej! llvm-svn: 247163
* [clang-tidy] Fix run-clang-tidy.py.Alexander Kornienko2015-09-081-2/+2
| | | | | | | | | | | | Do not add "-*" to the list of checks. Make consistent the list of enabled checks and the checks in use. Moreover, removing "-*" makes the behaviour consistent with clang-tidy and allows user to use .clang-tidy configuration... http://reviews.llvm.org/D12687 Patch by Marek Kurdej! llvm-svn: 247002
* [clang-tidy] Updated docs.Alexander Kornienko2015-09-081-6/+8
| | | | llvm-svn: 246996
* Avoid using rvalue references with trivially copyable types.Angel Garcia Gomez2015-09-083-40/+63
| | | | | | | | | | | | | | | | Summary: When the dereference operator returns a value that is trivially copyable (like a pointer), copy it. After this change, modernize-loop-convert check can be applied to the whole llvm source code without breaking any build or test. Reviewers: alexfh, klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D12675 llvm-svn: 246989
* Avoid repeated replacements on loop-convert check.Angel Garcia Gomez2015-09-042-9/+22
| | | | | | | | | | | | Summary: The InitListExpr subtree is visited twice, this caused the check to do multiple replacements. Added a set to avoid it. Reviewers: klimek, alexfh Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D12631 llvm-svn: 246879
OpenPOWER on IntegriCloud