summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Don't compute the edit distance if it's over the threshold.Benjamin Kramer2017-08-091-2/+2
| | | | | | No functional change intended. llvm-svn: 310532
* [clang-tidy] Fix another crash in make-unique check.Haojian Wu2017-08-091-0/+7
| | | | | | | | | | | | | | | | | Summary: The crash happens when calling `reset` method without any preceding operation like "->" or ".", this could happen in a subclass of the "std::unique_ptr". Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36452 llvm-svn: 310496
* [clang-tidy] Ignore newlines in checks listAlexander Kornienko2017-08-091-1/+1
| | | | | | | This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that LLVM YAML parser doesn't support multiline literal folding. llvm-svn: 310491
* [clang-tidy] Add new readability non-idiomatic static access checkGabor Horvath2017-08-084-0/+137
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D35937 llvm-svn: 310371
* [clang-tidy] 'implicit cast' -> 'implicit conversion'Alexander Kornienko2017-08-088-70/+69
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch renames checks, check options and changes messages to use correct term "implicit conversion" instead of "implicit cast" (which has been in use in Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++ standard). * performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop * readability-implicit-bool-cast -> readability-implicit-bool-conversion - readability-implicit-bool-cast.AllowConditionalIntegerCasts -> readability-implicit-bool-conversion.AllowIntegerConditions - readability-implicit-bool-cast.AllowConditionalPointerCasts -> readability-implicit-bool-conversion.AllowPointerConditions Reviewers: hokein, jdennett Reviewed By: hokein Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36456 llvm-svn: 310366
* [clang-tidy] Ignore macros in make-unique check.Haojian Wu2017-08-042-2/+27
| | | | | | | | | | | | | | | | Summary: The check doesn't fully support smart-ptr usages inside macros, which may cause incorrect fixes, or even crashes, ignore them for now. Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36264 llvm-svn: 310050
* [clang-tidy] Support initializer-list constructor cases in ↵Haojian Wu2017-08-041-10/+27
| | | | | | | | | | | | | | modernize-make-unique. Reviewers: alexfh Reviewed By: alexfh Subscribers: malcolm.parsons, JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36016 llvm-svn: 310035
* Adapt clang-tidy checks to changing semantics of hasDeclaration.Manuel Klimek2017-08-0212-77/+98
| | | | | | Differential Revision: https://reviews.llvm.org/D36154 llvm-svn: 309810
* [clang-tidy] Handle anonymous structs/unions in member init checks.Malcolm Parsons2017-08-012-12/+14
| | | | | | | | | | | | Use getAnyMember() instead of getMember() to avoid crash on anonymous structs/unions. Don't warn about initializing members of an anonymous union. Fixes PR32966. Reviewed by alexfh. llvm-svn: 309668
* [clang-tidy] readability-redundant-declaration: ignore friends and macrosAlexander Kornienko2017-07-282-5/+19
| | | | llvm-svn: 309379
* [clang-tidy] Do not issue fixit for explicit template specializationsFelix Berger2017-07-261-1/+15
| | | | | | | | | | | | | | Summary: Do not issue fixit in UnnecessaryValueParamCheck if the function is an explicit template specialization as this could cause build breakages. Reviewers: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D35718 llvm-svn: 309067
* [clang-tidy] Handle incomplete types in bugprone-undefined-memory-manipulationGabor Horvath2017-07-251-1/+2
| | | | | | | | | | check Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D35790 llvm-svn: 308954
* [clang-tidy] Add option to export fixes to run-clang-tidy.pyAlexander Kornienko2017-07-211-8/+46
| | | | | | | | | | | | | | | This patch adds the option to keep the list of proposed fixes even though they should not be applied. This allows to detect possible fixes using the parallelised run-clang-tidy.py and apply them using clang-apply-replacements at a later time. Essentially the patch causes the individual temporary yaml files by the parallel clang-tidy instances to be merged into one user-defined file. Patch by Michael F. Herbst! Differential revision: https://reviews.llvm.org/D31326 llvm-svn: 308726
* [clang-tidy] s/1/true/, NFCAlexander Kornienko2017-07-201-1/+1
| | | | llvm-svn: 308621
* [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are usedAlexander Kornienko2017-07-2015-36/+21
| | | | llvm-svn: 308605
* [NFC] Update function call names as changed in MacroInfo that should refer ↵Faisal Vali2017-07-172-3/+3
| | | | | | | | | | to Parameters (as opposed to Arguments). This syncs them up with clang commit r308190 Thanks! llvm-svn: 308191
* [clang-tidy] Add modernize-use-bool-literals.IgnoreMacros optionAlexander Kornienko2017-07-172-3/+15
| | | | llvm-svn: 308181
* [clang-tidy] Add bugprone-undefined-memory-manipulation checkGabor Horvath2017-07-144-0/+102
| | | | | | | | Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D35051 llvm-svn: 308021
* [clang-tidy] Add bugprone-suspicious-memset-usage checkGabor Horvath2017-07-1411-139/+223
| | | | | | | | | | | | | | | | | | Created new module bugprone and placed the check in that. Finds memset() calls with potential mistakes in their arguments. Replaces and extends the existing google-runtime-memset-zero-length check. Cases covered: * Fill value is a character '0'. Integer 0 might have been intended. * Fill value is out of char range and gets truncated. * Byte count is zero. Potentially swapped with the fill value argument. Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D32700 llvm-svn: 308020
* [clang-tidy] Add a new Android check "android-cloexec-socket"Yan Wang2017-07-127-29/+133
| | | | | | | | | | | | | | | | Summary: socket() is better to include SOCK_CLOEXEC in its type argument to avoid the file descriptor leakage. Reviewers: chh, Eugene.Zelenko, alexfh, hokein, aaron.ballman Reviewed By: chh, alexfh Subscribers: srhines, mgorny, JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34913 llvm-svn: 307818
* [clang-tidy] Ignore blank spaces between cast's ")" and its sub expr.Haojian Wu2017-07-121-5/+7
| | | | | | | | | | | | | | | | | | | | | Summary: Before the change: `auto i = (Enum) 5;` => `auto i = static_cast<Enum>( 5);` After the change: `auto i = (Enum) 5;` => `auto i = static_cast<Enum>(5);` Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D31700 llvm-svn: 307812
* [clang-tidy] Add new modernize use unary assert checkGabor Horvath2017-07-124-0/+85
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D35257 llvm-svn: 307791
* [clang-tidy] add_new_check.py updates ReleaseNotes.rst nowAlexander Kornienko2017-07-121-0/+32
| | | | llvm-svn: 307787
* [clang-tidy] Fix modernize-use-override incorrect replacementAlexander Kornienko2017-07-071-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For the following code: `modernize-use-override` generates a replacement with incorrect location. ``` struct IntPair { int first, second; }; struct A { virtual void il(IntPair); }; struct B : A { void il(IntPair p = {1, (2 + 3)}) {}; // Generated Fixit: void il(IntPair p = override {1, (2 + 3)}) {}; // Should be: void il(IntPair p = {1, (2 + 3)}) override {}; }; ``` This fixes that and adds a unit test. Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Victor Gao! Differential Revision: https://reviews.llvm.org/D35078 llvm-svn: 307379
* [clang-tidy] Add "MakeSmartPtrFunction" option to ↵Haojian Wu2017-07-052-8/+54
| | | | | | | | | | | | | | modernize-make-shared/unique checks. Reviewers: alexfh, aaron.ballman Reviewed By: alexfh Subscribers: JDevlieghere, Eugene.Zelenko, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34206 llvm-svn: 307130
* [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positiveJonas Devlieghere2017-07-031-0/+3
| | | | | | | | | | | | | | | | Summary: https://bugs.llvm.org/show_bug.cgi?id=33557 Reviewers: Eugene.Zelenko, alexfh, aaron.ballman, hokein Reviewed By: aaron.ballman, hokein Subscribers: cfe-commits, nemanjai, xazax.hun, kbarton Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34932 llvm-svn: 307040
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding LLVM change is r306878. llvm-svn: 306879
* [clang-tidy] Rename android-file-open-flag and fix a bugYan Wang2017-06-294-20/+22
| | | | | | | | | | | | | | | | | | Summary: 1. Rename android-file-open-flag to android-cloexec-open. 2. Handle a case when the function is passed as an argument of a function-like macro. Reviewers: chh Reviewed By: chh Subscribers: srhines, mgorny, JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34633 llvm-svn: 306728
* [clang-tidy][Part3] Add a new module Android and three new checks.Yan Wang2017-06-294-0/+115
| | | | | | | | | | | | | | | | Summary: -- fopen() should include "e" in their mode string. [android-fopen-mode] Reviewers: chh, alexfh, aaron.ballman, hokein Reviewed By: hokein Subscribers: JDevlieghere, srhines, mgorny, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33747 llvm-svn: 306709
* [clang-tidy][Part2] Add a new module Android and three new checksYan Wang2017-06-294-0/+97
| | | | | | | | | | | | | | | | Summary: -- creat() should be replaced by open(). [android-creat-usage] Reviewers: chh, alexfh, aaron.ballman, hokein Reviewed By: hokein Subscribers: JDevlieghere, srhines, mgorny, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33745 llvm-svn: 306708
* [clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument.Haojian Wu2017-06-291-1/+1
| | | | | | | | | | | | Reviewers: alexfh Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34526 llvm-svn: 306651
* [clang-tidy] Enable inline variable definitions in headersGabor Horvath2017-06-281-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D34449 llvm-svn: 306538
* [clang-tidy] Handle new array expressions in modernize-make-unique check.Haojian Wu2017-06-272-14/+45
| | | | | | | | | | | | Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34674 llvm-svn: 306421
* [NFC] Update to account for DiagnosticRenderer use of FullSourceLocPeter Smith2017-06-271-25/+22
| | | | | | | | | | | | | | D31709 [NFC] Refactor DiagnosticRenderer to use FullSourceLoc was committed in r305684 and reverted in 305688 as clang-tidy and clang-query failed to build. This change updates the extra tools to use the new interface. Reviewers: christof, rnk, rsmith, rovka, alexfh Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D34513 llvm-svn: 306385
* [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks.Haojian Wu2017-06-271-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If the class being created in unique_ptr is in anonymous nampespace, the anonymous namespace will be included in the apply-fixes. This patch fix this. ``` namespace { class Foo {}; } std::unique_ptr<Foo> f; f.reset(new Foo()); // Before the change: f = std::make_unique<(annonymous namespace)::Foo>(); // After the change: f = std::make_unique<Foo>(); ``` Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34286 llvm-svn: 306378
* [clang-tidy][Part1] Add a new module Android and three new checks.Yan Wang2017-06-238-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A common source of security bugs is code that opens a file descriptors without using the O_CLOEXEC flag. (Without that flag, an opened sensitive file would remain open across a fork+exec to a lower-privileged SELinux domain, leaking that sensitive data.). Add a new Android module and one checks in clang-tidy. -- open(), openat(), and open64() should include O_CLOEXEC in their flags argument. [android-file-open-flag] Links to part2 and part3: https://reviews.llvm.org/D33745 https://reviews.llvm.org/D33747 Reviewers: chh, alexfh, aaron.ballman, hokein Reviewed By: alexfh, hokein Subscribers: jbcoe, joerg, malcolm.parsons, Eugene.Zelenko, srhines, mgorny, xazax.hun, cfe-commits, krytarowski Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33304 llvm-svn: 306165
* [clang-tidy] Fix a false positive in modernize-use-nullptr.Haojian Wu2017-06-231-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The FP happens when a casting nullptr expression is used within a NULL-default-arguemnt cxx constructor. Before the fix, the check will give a warning on nullptr when running with the test case, which should not happen: ``` G(g(static_cast<char*>(nullptr))); ^~~~~~~~~~~ nullptr ``` Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, xazax.hun Differential Revision: https://reviews.llvm.org/D34524 llvm-svn: 306091
* [clang-tidy] readability-function-size: fix nesting level calculationRoman Lebedev2017-06-161-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A followup for D32942. Malcolm Parsons has provided a valid testcase that the initial version of the check complained about nested `if`'s. As it turns out, the culprit is the **partially** un-intentional `switch` fallthrough. So rewrite the NestingThreshold logic without ab-using+mis-using that switch with fallthrough, and add testcases with nested `if`' where there should be a warning and shouldn't be a warning. This results in a cleaner, simpler code, too. I guess, now it would be actually possible to pick some reasonable default for `NestingThreshold` setting. Fixes PR33454. Reviewers: malcolm.parsons, alexfh Reviewed By: malcolm.parsons Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34202 llvm-svn: 305554
* [clang-tidy] D33930: Do not pick up by default the LLVM style if passing ↵Vassil Vassilev2017-06-091-0/+4
| | | | | | | | | -format. This adds a new flag -style which is passed to clang-apply-replacements and defaults to file meaning it would pick up the closest .clang-format file in tree. llvm-svn: 305125
* [clang-tidy] readability-function-size: add NestingThreshold param.Roman Lebedev2017-06-092-8/+35
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Finds compound statements which create next nesting level after `NestingThreshold` and emits a warning. Do note that it warns about each compound statement that breaches the threshold, but not any of it's sub-statements, to have readable warnings. I was able to find only one coding style referencing nesting: - https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation > In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. This seems too basic, i'm not sure what else to test. Are more tests needed? Reviewers: alexfh, aaron.ballman, sbenza Reviewed By: alexfh, aaron.ballman Subscribers: xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D32942 llvm-svn: 305082
* Revert "[clang-tidy] When" -fno-exceptions is used", this warning is better ↵Alexander Kornienko2017-06-091-1/+1
| | | | | | | | | | to be suppressed." This reverts commit r304949. https://reviews.llvm.org/D34002#775830 llvm-svn: 305057
* Wdocumentation fix.Simon Pilgrim2017-06-081-1/+1
| | | | llvm-svn: 304988
* [clang-tidy] New checker to replace dynamic exception specificationsAlexander Kornienko2017-06-084-0/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: New checker to replace dynamic exception specifications This is an alternative to D18575 which relied on reparsing the decl to find the location of dynamic exception specifications, but couldn't deal with preprocessor conditionals correctly without reparsing the entire file. This approach uses D20428 to find dynamic exception specification locations and handles all cases correctly. Reviewers: aaron.ballman, alexfh Reviewed By: aaron.ballman, alexfh Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb Patch by Don Hinton! Differential Revision: https://reviews.llvm.org/D20693 llvm-svn: 304977
* [clang-tidy] When" -fno-exceptions is used", this warning is better to be ↵Yan Wang2017-06-071-1/+1
| | | | | | | | | | | | | | | | | | suppressed. Summary: "misc-noexcept-move-constructor" is better not to be issued when "-fno-exceptions" is set. Reviewers: chh, alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, cfe-commits, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34002 llvm-svn: 304949
* [clang-tidy] When" -fno-exceptions is used", this warning is better to be ↵Yan Wang2017-06-071-1/+1
| | | | | | | | | | | | | | | | | | suppressed. Summary: clang-tidy is better not to issues this warning, which checks where the initializer for the object may throw an exception, when "-fno-exceptions" is used. Reviewers: chh, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33917 llvm-svn: 304931
* [clang-tidy] Make misc-inaccurate-erase work with real C++11 containers.Alexander Kornienko2017-06-071-14/+16
| | | | | | | | The check failed to match iterator->const_iterator conversion that is happening at least when using the libstdc++'s vector. We might want to make it match even more flexible patterns, if we see more false negatives. llvm-svn: 304879
* [clang-tidy] misc-inaccurate-erase: support call by pointerAlexander Kornienko2017-06-061-3/+8
| | | | | | + replace matchesName calls with more efficient alternatives. llvm-svn: 304811
* [clang-tidy] Make misc-static-assert accept assert(!"msg")Florian Gross2017-06-031-1/+3
| | | | | | | | Added negated string literals to the set of IsAlwaysFalse expressions to avoid flagging of assert(!"msg"). Differential Revision: http://reviews.llvm.org/D33827 llvm-svn: 304657
* [clang-tidy] Add `const` to operator() to fix a warning.Alexander Kornienko2017-06-021-1/+1
| | | | llvm-svn: 304583
* [clang-tidy] check for __func__/__FUNCTION__ in lambdasAlexander Kornienko2017-06-024-0/+154
| | | | | | | | | | | | Add a clang-tidy check for using func__/FUNCTION__ inside lambdas. This evaluates to the string operator(), which is almost never useful and almost certainly not what the author intended. Patch by Bryce Liu! Differential Revision: https://reviews.llvm.org/D33497 llvm-svn: 304570
OpenPOWER on IntegriCloud