summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Add check 'readability-redundant-member-init'Malcolm Parsons2016-10-204-0/+105
| | | | | | | | | | | | Summary: The check emits a warning if a member-initializer calls the member's default constructor with no arguments. Reviewers: sbenza, alexfh, aaron.ballman Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, cfe-commits, beanz Differential Revision: https://reviews.llvm.org/D24339 llvm-svn: 284742
* Use auto in for loopMalcolm Parsons2016-10-201-1/+1
| | | | llvm-svn: 284737
* [clang-tidy] Simplify modernize-use-defaultMalcolm Parsons2016-10-201-42/+7
| | | | | | | | | | | | | | Summary: clang-tidy now cleans up after replacements, so leave colon and comma removal to that. Reviewers: angelgarcia, alexfh, aaron.ballman, djasper, ioeric Subscribers: djasper, cfe-commits Differential Revision: https://reviews.llvm.org/D25769 llvm-svn: 284735
* [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.Haojian Wu2016-10-201-0/+5
| | | | | | | | | | | | | | | Summary: The matcher for matching "class with default constructor" still match some classes without default constructor, which trigger an assert at Line 307. This patch makes the matcher more strict. Reviewers: aaron.ballman Subscribers: nemanjai, cfe-commits Differential Revision: https://reviews.llvm.org/D25747 llvm-svn: 284727
* [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.Haojian Wu2016-10-201-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list. The check is modernize-avoid-bind. Consider the following: void bar(int x, int y); namespace N { void bar(int x, int y); } void foo(){ auto Test = std::bind(N::bar,1,1); } clang-tidy’s modernize-avoid-bind check suggests writing: void foo(){ auto Test =[] {return bar(1,1);}; } instead of: void foo(){ auto Test = [] {return N::bar(1,1);}; } So clang-tidy has proposed an incorrect Fix. Patch by IdrissRio! Reviewers: alexfh, hokein, aaron.ballman Subscriber: cfe-commits llvm-svn: 284719
* [clang-tidy] Add cert-err09-cpp check alias.Marek Kurdej2016-10-191-0/+2
| | | | | | | | | | | | Summary: This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp. Reviewers: alexfh, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25770 llvm-svn: 284596
* [clang-tidy] Clean up code after applying replacements.Alexander Kornienko2016-10-173-26/+83
| | | | | | | | | | | | | | | Summary: Remove empty namespaces and initializer list commas / colons in affected ranges. Initial patch: proper options for enabling the cleanup and specifying the format style are needed. Reviewers: hokein, ioeric Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24572 llvm-svn: 284399
* Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-177-0/+345
| | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 284368
* [clang-tidy] Use ignoreImplicit in cert-err58-cpp checkMalcolm Parsons2016-10-161-2/+2
| | | | | | | | | | | | | | Summary: Fix a false negative in cert-err58-cpp check when calling a constructor creates objects that require cleanup. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25642 llvm-svn: 284332
* [clang-tidy] Add additional diagnostic to misc-use-after-moveMartin Bohme2016-10-141-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds a diagnostic to the misc-use-after-move check that is output when the use happens on a later loop iteration than the move, for example: A a; for (int i = 0; i < 10; ++i) { a.foo(); std::move(a); } This situation can be confusing to users because, in terms of source code location, the use is above the move. This can make it look as if the warning is a false positive, particularly if the loop is long but the use and move are close together. In cases like these, misc-use-after-move will now output an additional diagnostic: a.cpp:393:7: note: the use happens in a later loop iteration than the move Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25612 llvm-svn: 284235
* [clang-tidy] Fix readability-braces-around-statements false positiveMarek Kurdej2016-10-142-2/+3
| | | | | | | | | | | | | | | | | Summary: This fixes a false-positive e.g. when string literals are returned from if statement. This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check. Reviewers: alexfh, hokein Subscribers: hokein Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D25558 llvm-svn: 284212
* Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-126-342/+0
| | | | | | This reverts commit r283981. This patch breaks the buildbot. llvm-svn: 283985
* [ClangTidy] Add UsingInserter and NamespaceAliaserHaojian Wu2016-10-126-0/+342
| | | | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 283981
* [clang-tidy] Ignore empty members and bases in ↵Malcolm Parsons2016-10-111-1/+24
| | | | | | | | | | | | | | cppcoreguidelines-pro-type-member-init Summary: Empty/incomplete variables/members/bases don't need to be initialized Reviewers: mgehre, aaron.ballman, alexfh Subscribers: nemanjai, cfe-commits Differential Revision: https://reviews.llvm.org/D25238 llvm-svn: 283886
* [clang-tidy] Fix template agrument false positives in unused-using-decls.Haojian Wu2016-10-111-0/+14
| | | | | | | | | | | | | | Summary: * Fix a false postive when an using class is used in an explicit template instantiation. * Fix a false postive when an using template class is used as template argument. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25437 llvm-svn: 283879
* [clang-tidy] readability-avoid-const-params-in-decls template instantiation ↵Malcolm Parsons2016-10-111-1/+6
| | | | | | | | | | | | | | bugfix Summary: Bugfix for 30398. Don't warn for template instantiations Reviewers: aaron.ballman, hokein, alexfh Subscribers: omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D24652 llvm-svn: 283873
* [clang-tidy] modernize-use-default default constructor bugfixMalcolm Parsons2016-10-111-7/+7
| | | | | | | | | | | | | | Summary: Only member initializers that are written should prevent using '= default' on a default constructor. Reviewers: klimek, sbenza, aaron.ballman, alexfh Subscribers: Eugene.Zelenko, alexfh, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24444 llvm-svn: 283869
* [clang-tidy] Add a whitelist option in google-runtime-references.Haojian Wu2016-10-102-2/+29
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25244 llvm-svn: 283777
* Revert "Revert "Add a static_assert to enforce that parameters to ↵Mehdi Amini2016-10-071-2/+2
| | | | | | | | | llvm::format() are not totally unsafe"" This reverts commit r283510 and reapply r283509, with updates to clang-tools-extra as well. llvm-svn: 283525
* Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle ↵Aaron Ballman2016-10-043-35/+67
| | | | | | | | | | classes with default constructors that are defaulted or are not present in the AST. Classes with virtual methods or virtual bases are not trivially default constructible, so their members and bases need to be initialized. Patch by Malcolm Parsons. llvm-svn: 283224
* [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init ↵Matthias Gehre2016-09-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with in-class initializers Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where ``` warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init] ``` is emitted on ``` struct MyStruct { int a = 5; int b = 7; }; int main() { MyStruct s; } ``` Reviewers: alexfh, aaron.ballman Subscribers: nemanjai, cfe-commits Differential Revision: https://reviews.llvm.org/D24848 llvm-svn: 282625
* [clang-tidy] Use isStaticStorageClass ast matcher.Haojian Wu2016-09-271-12/+6
| | | | llvm-svn: 282476
* Silence a false positive with the cert-err58-cpp check; now allows objects ↵Aaron Ballman2016-09-261-2/+2
| | | | | | | | with static or thread storage duration at function block scope. Patch by Malcolm Parsons llvm-svn: 282409
* [clang-tidy] make readability-redundant-smartptr-get report get() usage in ↵Kirill Bobyrev2016-09-261-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | conditions This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases: ``` std::unique_ptr<void> ptr; if (ptr.get()) if (ptr.get() == NULL) if (ptr.get() != NULL) ``` This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko. However, there still are cases not detected by the check. They can be found in `void Negative()` function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24893 llvm-svn: 282386
* Revert r282382; it had no reference to Revision.Kirill Bobyrev2016-09-261-18/+11
| | | | llvm-svn: 282384
* [clang-tidy] make readability-redundant-smartptr-get report get() usage in ↵Kirill Bobyrev2016-09-261-11/+18
| | | | | | | | | | | | | | | | | | | | | | | conditions This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases: ``` std::unique_ptr<void> ptr; if (ptr.get()) if (ptr.get() == NULL) if (ptr.get() != NULL) ``` This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko. However, there still are cases not detected by the check. They can be found in `void Negative()` function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp. llvm-svn: 282382
* [clang-tidy] fix for NOLINT after macro expansionMatthias Gehre2016-09-241-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When having ``` c++ #define MACRO code-with-warning MACRO; // NOLINT ``` clang-tidy would still show the warning, because it searched for "NOLINT" only in the first line, not on the second. This caused e.g. https://llvm.org/bugs/show_bug.cgi?id=29089 (where the macro was defined in a system header). See also the added test cases. Now clang-tidy looks at the line of macro invocation and every line of macro definition for a NOLINT comment. Reviewers: alexfh, aaron.ballman, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24845 llvm-svn: 282330
* [clang-tidy] Cleaning up language options.Gabor Horvath2016-09-2428-81/+67
| | | | | | Differential Revision: https://reviews.llvm.org/D24881 llvm-svn: 282319
* [clang-tidy] Add doc for `explain-config` option.Haojian Wu2016-09-221-2/+3
| | | | llvm-svn: 282158
* [clang-tidy] Bugfix for readability-redundant-control-flow checkKirill Bobyrev2016-09-161-1/+1
| | | | | | | | | | | | | This check did not create FixItHints when the statement before the redundant control flow was not followed by a semicolon. Patch by Malcolm Parsons! Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24500 llvm-svn: 281713
* [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModuleMartin Bohme2016-09-141-0/+1
| | | | | | | | | | | | | Summary: This is needed for the recently submitted misc-use-after-move check (rL281453). For some reason, this still built under Linux, but it caused the PPC build bot to fail. Subscribers: beanz, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D24561 llvm-svn: 281460
* [clang-tidy] Add check 'misc-use-after-move'Martin Bohme2016-09-144-0/+682
| | | | | | | | | | | | | | | | Summary: The check warns if an object is used after it has been moved, without an intervening reinitialization. See user-facing documentation for details. Reviewers: sbenza, Prazek, alexfh Subscribers: beanz, mgorny, shadeware, omtcyfz, Eugene.Zelenko, Prazek, fowles, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D23353 llvm-svn: 281453
* [clang-tidy] Fix naming in container-size-empty.Kirill Bobyrev2016-09-131-4/+4
| | | | llvm-svn: 281313
* [clang-tidy] Extend readability-container-size-empty to arbitrary class with ↵Kirill Bobyrev2016-09-131-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | size() and empty() This patch extends readability-container-size-empty check allowing it to produce warnings not only for STL containers, but also for containers, which provide two functions matching following signatures: * `size_type size() const;` * `bool empty() const;` Where `size_type` can be any kind of integer type. This functionality was proposed in https://llvm.org/bugs/show_bug.cgi?id=26823 by Eugene Zelenko. Approval: alexfh Reviewers: alexfh, aaron.ballman, Eugene.Zelenko Subscribers: etienneb, Prazek, hokein, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D24349 llvm-svn: 281307
* [clang-tidy] readability-misplaced-array-index: add new check that warns ↵Daniel Marjamaki2016-09-124-0/+97
| | | | | | | | | | when array index is misplaced. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D21134 llvm-svn: 281206
* [clang-tidy] modernize-make-{smart_ptr} private ctor bugfixPiotr Padlewski2016-08-311-1/+7
| | | | | | | | | | | | | | | Summary: Bugfix for 27321. When the constructor of stored pointer type is private then it is invalid to change it to make_shared or make_unique. Reviewers: alexfh, aaron.ballman, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23343 llvm-svn: 280180
* [clang-tidy] Add check 'misc-move-forwarding-reference'Martin Bohme2016-08-304-0/+187
| | | | | | | | | | | | | | | | | | | | | | | Summary: The check emits a warning if std::move() is applied to a forwarding reference, i.e. an rvalue reference of a function template argument type. If a developer is unaware of the special rules for template argument deduction on forwarding references, it will seem reasonable to apply std::move() to the forwarding reference, in the same way that this would be done for a "normal" rvalue reference. This has a consequence that is usually unwanted and possibly surprising: If the function that takes the forwarding reference as its parameter is called with an lvalue, that lvalue will be moved from (and hence placed into an indeterminate state) even though no std::move() was applied to the lvalue at the callsite. As a fix, the check will suggest replacing the std::move() with a std::forward(). This patch requires D23004 to be submitted before it. Reviewers: sbenza, aaron.ballman Subscribers: klimek, etienneb, alexfh, aaron.ballman, Prazek, Eugene.Zelenko, mgehre, cfe-commits Projects: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D22220 llvm-svn: 280077
* [clang-tidy] Some tweaks on header guard checks.Haojian Wu2016-08-264-25/+30
| | | | | | | | * Implement missing storeOption interfaces. * Remove unnecessary parameter copy in isHeaderFileExtension. * Fix doc style. llvm-svn: 279814
* [clang-tidy] Added hh, hxx and hpp to header guard checks.Mads Ravn2016-08-266-8/+54
| | | | | | | | Changed the extension check to include the option of ",h,hh,hpp,hxx" instead of just returning whether the file ended with ".h". Differential revision: https://reviews.llvm.org/D20512 llvm-svn: 279803
* [clang-tidy misc-move-const-arg] more specific messages + suggest ↵Alexander Kornienko2016-08-241-4/+9
| | | | | | alternative solution llvm-svn: 279666
* [clang-tidy] Merge ExtraArgs(Before) instead of overriding them.Alexander Kornienko2016-08-231-24/+30
| | | | | | Added proper tests. llvm-svn: 279519
* [clang-tidy] Fix the order of ExtraArgsBeforeAlexander Kornienko2016-08-231-4/+8
| | | | | | Added tests for the relative order of -extra-arg(-before) and ExtraArgs(Before). llvm-svn: 279516
* [clang-tidy] readability-non-const-parameter: add new check that warns when ↵Daniel Marjamaki2016-08-234-0/+282
| | | | | | | | | | | | | | function parameters should be const The check will warn when the constness will make the function interface safer. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D15332 llvm-svn: 279507
* minor header guards and help messages cleanupKirill Bobyrev2016-08-191-1/+1
| | | | llvm-svn: 279226
* Adapt to TraverseLambdaCapture interface change from D23204Martin Bohme2016-08-172-3/+5
| | | | | | | | | | | | | | | Summary: Depends on D23204. This is intended to be submitted immediately after D23204 lands. Reviewers: jdennett, alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23543 llvm-svn: 278934
* [clang-tidy] readability-implicit-bool-cast forgets to store its options.Haojian Wu2016-08-162-6/+19
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23544 llvm-svn: 278791
* [clang-tidy] MPIBufferDerefCheck Alexander Droste2016-08-124-0/+186
| | | | | | | | | | | | | | | | | | ... This check verifies if a buffer passed to an MPI (Message Passing Interface) function is sufficiently dereferenced. Buffers should be passed as a single pointer or array. As MPI function signatures specify void * for their buffer types, insufficiently dereferenced buffers can be passed, like for example as double pointers or multidimensional arrays, without a compiler warning emitted. Instructions on how to apply the check can be found at: https://github.com/0ax1/MPI-Checker/tree/master/examples Reviewers: Haojian Wu Differential revision: https://reviews.llvm.org/D22729 llvm-svn: 278553
* Analyze include order on a per-file basis.Zachary Turner2016-08-121-60/+70
| | | | | | | | | | | | | | | | | | | The include order check would get notified of all include directives in a depth-first manner. This created the possibility of an include directive from a header file interfering with the sort order of a set of two distinct blocks from the top level cpp file, if that include directive was on just the right line. With this patch we bucket the include directives by the file in which they appear in and process one bucket at a time, so that directives from different files do not get mixed together into the same list. Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D23434 llvm-svn: 278546
* [clang-tidy] enhance readability-else-after-returnKirill Bobyrev2016-08-101-7/+16
| | | | | | | | | | | | `readability-else-after-return` only warns about `return` calls, but LLVM Coding Standars stat that `throw`, `continue`, `goto`, etc after `return` calls are bad, too. Reviwers: alexfh, aaron.ballman Differential Revision: https://reviews.llvm.org/D23265 llvm-svn: 278257
* [clang-tidy] minor improvements in modernise-deprecated-headers checkKirill Bobyrev2016-08-101-15/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a minor list of changes as proposed by Richard Smith in the mailing list. See original comments with an impact on the future check state below: [comments.begin > + {"complex.h", "ccomplex"}, It'd be better to convert this one to <complex>, or leave it alone. <ccomplex> is an unnecessary wart. (The contents of C++11's <complex.h> / <ccomplex> / <complex> (all of which are identical) aren't comparable to C99's <complex.h>, so if this was C++98 code using the C99 header, the code will be broken with or without this transformation.) > + {"iso646.h", "ciso646"}, Just delete #includes of this one. <ciso646> does nothing. > + {"stdalign.h", "cstdalign"}, > + {"stdbool.h", "cstdbool"}, We should just delete these two includes. These headers do nothing in C++. comments.end] Reviewers: alexfh, aaron.ballman Differential Revision: https://reviews.llvm.org/D17990 llvm-svn: 278254
OpenPOWER on IntegriCloud