summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Add a module for the Linux kernel.Tom Roeder2019-07-251-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Now that clang is going to be able to build the Linux kernel again on x86, and we have gen_compile_commands.py upstream for generating compile_commands.json, clang-tidy can be used on the Linux kernel source. To that end, this commit adds a new clang-tidy module to be used for checks specific to Linux kernel source. The Linux kernel follows its own style of C, and it will be useful to separate those checks into their own module. This also adds an initial check that makes sure that return values from the kernel error functions like PTR_ERR and ERR_PTR are checked. It also makes sure that any functions that directly return values from these functions are checked. Subscribers: xazax.hun, gribozavr, Eugene.Zelenko, lebedev.ri, mgorny, jdoerfert, cfe-commits Tags: #clang, #clang-tools-extra Reviewers: aaron.ballman, alexfh, hokein, JonasToth Differential Revision: https://reviews.llvm.org/D59963 llvm-svn: 367071
* [clang-tidy] Exclude forward decls from fuchsia-multiple-inheritanceJulie Hockett2019-07-171-0/+3
| | | | | | | | Addresses b39770. Differential Revision: https://reviews.llvm.org/D64813 llvm-svn: 366354
* [clang-tidy] Fix crash on end location inside macroNathan Huckleberry2019-07-171-0/+14
| | | | | | | | | | | | | | | | | | | | Summary: Lexer::getLocForEndOfToken is defined to return an invalid location if the given location is inside a macro. Other checks conditionally warn based off location validity. Updating this check to do the same. Reviewers: JonasToth, aaron.ballman, nickdesaulniers Reviewed By: nickdesaulniers Subscribers: lebedev.ri, nickdesaulniers, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64607 llvm-svn: 366353
* [clang-tidy] Adjust location of namespace comment diagnosticIlya Biryukov2019-07-173-6/+6
| | | | | | | | | | | | | | | | | | | | | | Summary: If there is no comment, place it at the closing brace of a namespace definition. Previously it was placed at the next character after the closing brace. The new position produces a better location for highlighting in clangd and does not seem to make matters worse for clang-tidy. Reviewers: alexfh, hokein Reviewed By: alexfh, hokein Subscribers: xazax.hun, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64861 llvm-svn: 366337
* [clang-tidy] initial version of readability-convert-member-functions-to-staticMatthias Gehre2019-07-161-0/+218
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Finds non-static member functions that can be made ``static``. I have run this check (repeatedly) over llvm-project. It made 1708 member functions ``static``. Out of those, I had to exclude 22 via ``NOLINT`` because their address was taken and stored in a variable of pointer-to-member type (e.g. passed to llvm::StringSwitch). It also made 243 member functions ``const``. (This is currently very conservative to have no false-positives and can hopefully be extended in the future.) You can find the results here: https://github.com/mgehre/llvm-project/commits/static_const_eval Reviewers: alexfh, aaron.ballman Subscribers: mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61749 llvm-svn: 366265
* Enhance abseil-faster-strsplit-delimiter to handle other non-printable ↵Dmitri Gribenko2019-07-091-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | characters. Summary: Currently it fails on cases like '\001'. Note: Since `StringLiteral::outputString` dumps most nonprintable characters in octal value, the exact string literal format isn't preserved, e.g. `"\x01"` becomes `'\001'`. Reviewers: gribozavr Reviewed By: gribozavr Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64151 Patch by Xiaoyi Zhang. llvm-svn: 365463
* A test commit following 'Obtaining Commit Access' ↵Jian Cai2019-07-081-1/+1
| | | | | | (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access) llvm-svn: 365380
* [clang-tidy] new check: bugprone-posix-returnDmitri Gribenko2019-07-031-0/+127
| | | | | | | | | | | | | | | | | | | | Summary: Checks if any calls to posix functions (except posix_openpt) expect negative return values. These functions return either 0 on success or an errno on failure, which is positive only. Reviewers: JonasToth, gribozavr, alexfh, hokein Reviewed By: gribozavr Subscribers: Eugene.Zelenko, lebedev.ri, llozano, george.burgess.iv, xazax.hun, srhines, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63623 Patch by Jian Cai. llvm-svn: 365007
* [NFC] Marking test added in r363975 as unsupported on Windows.Douglas Yung2019-06-221-0/+2
| | | | | | | | This test references a path that does not exist on Windows causing it to emit different output from what was expected leading to a failure when run on Windows. llvm-svn: 364120
* [clang-tidy] misc-unused-parameters: don't comment out parameter name for C codeMatthias Gehre2019-06-211-1/+1
| | | | | | | | | | | | | | Summary: The fixit `int square(int /*num*/)` yields `error: parameter name omitted` for C code. Enable it only for C++ code. Reviewers: klimek, ilya-biryukov, lebedev.ri, aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63088 llvm-svn: 364106
* [clang-tidy] Move test files of rL363975 into Inputs directoryKadir Cetinkaya2019-06-212-1/+1
| | | | llvm-svn: 364008
* [clang-tidy] Fail gracefully upon empty database fieldsSerge Guelton2019-06-202-0/+7
| | | | | | | | Fix bz#42281 Differential Revision: https://reviews.llvm.org/D63613 llvm-svn: 363975
* Fix more tests after r363749Aaron Puchert2019-06-191-0/+14
| | | | | | | Apparently -Wmissing-prototypes is used for quite a few integration tests. llvm-svn: 363760
* [clang-tidy] Split fuchsia-default-argumentsJulie Hockett2019-06-182-31/+44
| | | | | | | | | | | | Splits fuchsia-default-arguments check into two checks. fuchsia-default-arguments-calls warns if a function or method is called with default arguments. fuchsia-default-arguments-declarations warns if a function or method is declared with default parameters. Committed on behalf of @diegoast (Diego Astiazarán). Resolves b38051. Differential Revision: https://reviews.llvm.org/D62437 llvm-svn: 363712
* [clang-tidy] Made abseil-faster-strsplit-delimiter tests pass on C++17Dmitri Gribenko2019-06-131-1/+1
| | | | | | | | | | | | | | | | Reviewers: hokein, gribozavr Reviewed By: hokein, gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63253 Patch by Johan Vikström. llvm-svn: 363273
* [clang-tidy] Fixed abseil-time-subtraction to work on C++17Dmitri Gribenko2019-06-131-1/+1
| | | | | | | | | | | | | | | | Summary: Fixed abseil-time-subtraction to work on C++17 Reviewers: hokein, gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63261 Patch by Johan Vikström. llvm-svn: 363272
* [clang-tidy] Made abseil-upgrade-duration-conversions tests pass on c++17Dmitri Gribenko2019-06-131-1/+1
| | | | | | | | | | | | | | | | | | Summary: Made abseil-upgrade-duration-conversions tests pass on c++17 Reviewers: hokein, gribozavr Reviewed By: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63262 Patch by Johan Vikström. llvm-svn: 363270
* [clang-tidy] Fixed abseil-duration-unnecessary-conversion tests for c++17Dmitri Gribenko2019-06-131-2/+1
| | | | | | | | | | | | | | | | | | Summary: Fixed abseil-duration-unnecessary-conversion tests for c++17 Reviewers: hokein, gribozavr Reviewed By: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63263 Patch by Johan Vikström. llvm-svn: 363263
* Fixed a crash in misc-redundant-expression ClangTidy checkerDmitri Gribenko2019-06-121-1/+15
| | | | | | | | | | | | | | Summary: It was trying to pass a dependent expression into constant evaluator. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63188 llvm-svn: 363133
* [clang-tidy] Fix typo in bugprone-string-constructor.Clement Courbet2019-06-111-3/+3
| | | | | | s/bigger then/bigger than/ llvm-svn: 363053
* Fixed google-readability-casting test to work in c++17Dmitri Gribenko2019-06-111-1/+1
| | | | | | | | | | | | | | | | | | Summary: Fixed google-readability-casting.cpp to get tests working in c++17 Reviewers: gribozavr, hokein Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63128 Patch by Shaurya Gupta. llvm-svn: 363047
* [clang-tidy] Make the plugin honor NOLINTNikolai Kosjar2019-06-063-0/+99
| | | | | | | | | | | | | | | | | Instantiate a ClangTidyDiagnosticConsumer also for the plugin case and let it forward the diagnostics to the external diagnostic engine that is already in place. One minor difference to the clang-tidy executable case is that the compiler checks/diagnostics are referred to with their original name. For example, for -Wunused-variable the plugin will refer to the check as "-Wunused-variable" while the clang-tidy executable will refer to that as "clang-diagnostic- unused-variable". This is because the compiler diagnostics never reach ClangTidyDiagnosticConsumer. Differential Revision: https://reviews.llvm.org/D61487 llvm-svn: 362702
* [clang-tidy] Fix an assertion failure in misc-redundant-expression.Haojian Wu2019-06-061-0/+12
| | | | | | | | | | | | | | | | | Summary: The assertion "isIntegerConstantExpr" is triggered in the isIntegerConstantExpr(), we should not call it if the expression is value dependent. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62947 llvm-svn: 362701
* [clang-tidy] Fix make-unique tests on C++2a.Haojian Wu2019-06-063-70/+114
| | | | | | | | | | | | | | | | Summary: These test cases are illgal in C++2a ("new Foo{}" needs to see the default constructor), so move them to the C++14-only tests. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62845 llvm-svn: 362679
* android: add a close-on-exec check on pipe()George Burgess IV2019-06-061-0/+27
| | | | | | | | | | | On Android, pipe() is better to be replaced by pipe2() with O_CLOEXEC flag to avoid file descriptor leakage. Patch by Jian Cai! Differential Revision: https://reviews.llvm.org/D61967 llvm-svn: 362673
* android: add a close-on-exec check on pipe2()George Burgess IV2019-06-061-0/+68
| | | | | | | | | | | On Android, pipe2() is better to set O_CLOEXEC flag to avoid file descriptor leakage. Patch by Jian Cai! Differential Revision: https://reviews.llvm.org/D62049 llvm-svn: 362672
* [clang-tidy] Fix make-unique check to work in C++17 mode.Haojian Wu2019-06-031-6/+6
| | | | | | | | | | | | | | | | | | | | Summary: Previously, we intended to omit the check fix to the case when constructor has any braced-init-list argument. But the HasListInitializedArgument was not correct to handle all cases (Foo(Bar{1, 2}) will return false in C++14 mode). This patch fixes it, corrects the tests, and makes the check to run at C++17 mode. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62736 llvm-svn: 362361
* Revise the google-objc-global-variable-declaration check to match the style ↵Stephane Moore2019-05-311-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | guide. Summary: Revise the google-objc-global-variable-declaration check to match the style guide. This commit updates the check as follows: (1) Do not emit fixes for extern global constants. (2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers). https://google.github.io/styleguide/objcguide.html#prefixes This is an amended re-submission of https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d. Contributed By: yaqiji Reviewers: Wizard, benhamilton, stephanemoore Reviewed By: benhamilton, stephanemoore Subscribers: mgorny, cfe-commits, yaqiji Tags: #clang Differential Revision: https://reviews.llvm.org/D62045 llvm-svn: 362279
* Rollback "Revise the google-objc-global-variable-declaration check to match ↵Stephane Moore2019-05-291-17/+3
| | | | | | | | | | the style guide." 💥 The change introduced new test failures. Phabricator URL of original commit: https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d llvm-svn: 361914
* Revise the google-objc-global-variable-declaration check to match the style ↵Stephane Moore2019-05-291-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | guide. Summary: Revise the google-objc-global-variable-declaration check to match the style guide. This commit updates the check as follows: (1) Do not emit fixes for extern global constants. (2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers). https://google.github.io/styleguide/objcguide.html#prefixes Contributed by yaqiji. Reviewers: Wizard, benhamilton, stephanemoore Reviewed By: benhamilton, stephanemoore Subscribers: mgorny, cfe-commits, yaqiji Tags: #clang Differential Revision: https://reviews.llvm.org/D62045 llvm-svn: 361907
* [OpenMP] Set pragma start loc to `#pragma` locJoel E. Denny2019-05-281-10/+10
| | | | | | | | | | | | | | | This patch adjusts `PragmaOpenMPHandler` to set the location of `tok::annot_pragma_openmp` to the `#pragma` location instead of the `omp` location so that the former becomes the start location of the OpenMP AST node. This can be useful when, for example, rewriting a directive using Clang's Rewrite facility. Most of this patch updates tests for changes to locations in diagnostics and `-ast-dump` output. Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman Differential Revision: https://reviews.llvm.org/D61509 llvm-svn: 361867
* [clang-tidy] Fix description for misc-definitions-in-headers.Haojian Wu2019-05-281-0/+1
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62524 llvm-svn: 361834
* [clang-tidy] Verify fix description for misc-unused-using-decl.Haojian Wu2019-05-281-0/+1
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62522 llvm-svn: 361833
* [clang-tidy] Fix null pointer dereference in readability-identifier-namingHaojian Wu2019-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: readability-identifier-naming causes a null pointer dereference when checking an identifier introduced by a structured binding whose right hand side is an undeclared identifier. Running the check on a file that is just the following results in a crash: ``` auto [left] = right; ``` Patch by Mark Stegeman! Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: hokein, aaron.ballman Subscribers: madsravn, xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D62404 llvm-svn: 361809
* DeleteNullPointerCheck now deletes until the end brace of the condition.Mads Ravn2019-05-261-0/+9
| | | | | | | | Patch by Jonathan Camilleri Differential Revision https://reviews.llvm.org/D61861 llvm-svn: 361735
* Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on ↵Dmitri Gribenko2019-05-241-1/+1
| | | | | | | | | | platforms where char is unsigned The other options are to completely specify the triple (reduces test coverage), or to specify a regex that allows either '0' or '0U' for char initializers, however, that relaxes the test. llvm-svn: 361629
* Made cppcoreguidelines-pro-type-member-init-use-assignment run in all ↵Dmitri Gribenko2019-05-241-1/+1
| | | | | | language modes llvm-svn: 361628
* [clang-tidy] Add option "LiteralInitializers" to ↵Matthias Gehre2019-05-241-0/+40
| | | | | | | | cppcoreguidelines-pro-type-member-init Differential Revision: D24892 llvm-svn: 361601
* [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignmentTamas Zolnai2019-05-232-0/+57
| | | | | | | | | | | | | | | | | | | | Summary: Added WarnOnlyIfThisHasSuspiciousField option to allow to catch any copy assignment operator independently from the container class's fields. Added the cert alias using this option. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: mgorny, Eugene.Zelenko, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62192 llvm-svn: 361550
* [clang-tidy] New check calling out uses of +new in Objective-C codeDmitri Gribenko2019-05-231-0/+80
| | | | | | | | | | | | | | | | | | | | | Summary: Google's Objective-C style guide forbids calling or overriding +new to instantiate objects. This check warns on violations. Style guide reference: https://google.github.io/styleguide/objcguide.html#do-not-use-new Patch by Michael Wyman. Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, stephanemoore, mwyman Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman Subscribers: stephanemoore, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D61350 llvm-svn: 361487
* Disable the modernize-use-trailing-return-type.cpp test in C++2a modeDmitri Gribenko2019-05-201-1/+3
| | | | | | It is performing a use-of-uninitialized-value, as detected by MSan. llvm-svn: 361163
* Run ClangTidy tests in all C++ language modesDmitri Gribenko2019-05-20141-210/+282
| | | | | | | | | | | | | | | | | | | | | | | Summary: I inspected every test and did one of the following: - changed the test to run in all language modes, - added a comment explaining why the test is only applicable in a certain mode, - limited the test to language modes where it passes and added a FIXME to fix the checker or the test. Reviewers: alexfh, lebedev.ri Subscribers: nemanjai, kbarton, arphaman, jdoerfert, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62125 llvm-svn: 361131
* [clang-tidy] Handle member variables in readability-simplify-boolean-exprJonas Toth2019-05-161-0/+356
| | | | | | | | | | | | | | | | | - Add readability-simplify-boolean-expr test cases for member variables Fixes PR40179 Patch by LegalizeAdulthood. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: jdoerfert, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D56323 llvm-svn: 360882
* [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" ↵Don Hinton2019-05-152-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with correct attribution Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Patch by Torbjörn Klatt! Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360788
* Revert [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-152-22/+8
| | | | | | This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44) llvm-svn: 360787
* [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-152-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior to version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360785
* [clang-tidy] new check: bugprone-branch-cloneKristof Umann2019-05-151-0/+1026
| | | | | | | | | | | | | Implement a check for detecting if/else if/else chains where two or more branches are Type I clones of each other (that is, they contain identical code) and for detecting switch statements where two or more consecutive branches are Type I clones of each other. Patch by Donát Nagy! Differential Revision: https://reviews.llvm.org/D54757 llvm-svn: 360779
* [clang-tidy] Fix invalid fixit for ↵Matthias Gehre2019-05-141-0/+28
| | | | | | | | | | | | | | | | | | | readability-static-accessed-through-instance (bug 40544) Summary: Fixed https://bugs.llvm.org/show_bug.cgi?id=40544 Before, we would generate a fixit like `(anonymous namespace)::Foo::fun();` for the added test case. Reviewers: aaron.ballman, alexfh, xazax.hun Subscribers: rnkovacs, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D61874 llvm-svn: 360698
* [clang-tidy] readability-redundant-declaration: fix false positive with C ↵Matthias Gehre2019-05-132-0/+41
| | | | | | | | | | | | | | | | | | | "extern inline" Summary: readability-redundant-declaration was diagnosing a redundant declaration on "extern inline void f();", which is needed in C code to force an external definition of the inline function f. (This is different to how inline behaves in C++). Reviewers: alexfh, danielmarjamaki Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61700 llvm-svn: 360613
* [clang-tidy] new check: bugprone-unhandled-self-assignmentTamas Zolnai2019-05-121-0/+579
| | | | | | | | | | | | | | | | | | | | | Summary: This check searches for copy assignment operators which might not handle self-assignment properly. There are three patterns of handling a self assignment situation: self check, copy-and-swap or the less common copy-and-move. The new check warns if none of these patterns is found in a user defined implementation. See also: OOP54-CPP. Gracefully handle self-copy assignment https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP54-CPP.+Gracefully+handle+self-copy+assignment Reviewers: JonasToth, alexfh, hokein, aaron.ballman Subscribers: riccibruno, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D60507 llvm-svn: 360540
OpenPOWER on IntegriCloud