summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] readability-identifier-naming - Support for MacrosAlexander Kornienko2016-06-172-22/+187
| | | | | | | | | | | | | | | | | | | | | Summary: Added support for macro definitions. -- 1. Added a pre-processor callback to catch macro definitions 2. Changed the type of the failure map so that macros and declarations can share the same map 3. Added extra tests to ensure fix-ups work using the new map 4. Added fix-ups for type aliases in variable and function declarations as part of adding the new tests Reviewers: alexfh Subscribers: Eugene.Zelenko, cfe-commits Patch by James Reynolds! Differential Revision: http://reviews.llvm.org/D21020 llvm-svn: 272993
* [clang-tidy] misc-move-const-arg: Fix typosAlexander Kornienko2016-06-162-5/+5
| | | | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Patch by Martin Boehme! Differential Revision: http://reviews.llvm.org/D21366 llvm-svn: 272897
* [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being ↵Alexander Kornienko2016-06-161-21/+47
| | | | | | | | | | | | | | | | | | | | | | | | passed as a const ref argument Summary: Conceptually, this is very close to the existing functionality of misc-move-const-arg, which is why I'm adding it here and not creating a new check. For example, for a type A that is both movable and copyable, this const A a1; A a2(std::move(a1)); is not only a case where a const argument is being passed to std::move(), but the result of std::move() is also being passed as a const reference (due to overload resolution). The new check typically triggers (exclusively) in cases where people think they're dealing with a movable type, but in fact the type is not movable. Reviewers: hokein, aaron.ballman, alexfh Subscribers: aaron.ballman, cfe-commits Patch by Martin Boehme! Differential Revision: http://reviews.llvm.org/D21223 llvm-svn: 272896
* [clang-tidy] Remove dead code. NFC.Benjamin Kramer2016-06-152-17/+0
| | | | llvm-svn: 272803
* Apply performance-unnecessary-value-param to clang-tidy.Benjamin Kramer2016-06-156-10/+11
| | | | | | With minor manual tweaks. No functionality change intended. llvm-svn: 272795
* [clang-tidy] misc-argument-comment: don't bail out when an argument is a ↵Alexander Kornienko2016-06-082-13/+8
| | | | | | | | macro expansion (e.g. NULL). Add CHECK-FIX tests. llvm-svn: 272155
* [clang-tidy] correct clang-tidy-diff.py help messageAlexander Kornienko2016-06-081-5/+5
| | | | | | | | | | | | | | | | Summary: Looks like the original code was copied from clang-format-diff.py. Update help message to make it clang-tidy specific. Reviewers: klimek, alexfh Subscribers: Eugene.Zelenko, cfe-commits Patch by Igor Sugak! Differential Revision: http://reviews.llvm.org/D21050 llvm-svn: 272144
* [clang-tidy] misc-macro-parentheses - avoid adding parentheses in variable ↵Daniel Marjamaki2016-06-081-2/+49
| | | | | | | | | | | | | | declarations Fixes bugzilla issues 26273 and 27399 Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20853 llvm-svn: 272128
* Add the misc-misplaced-const check to clang-tidy, which diagnoses when a ↵Aaron Ballman2016-06-074-0/+103
| | | | | | const-qualifier is applied to a typedef of pointer type rather than to the pointee type. llvm-svn: 272025
* [clang-tidy] readability-identifier-naming - Support for Type AliasesAlexander Kornienko2016-06-071-0/+4
| | | | | | | | | | | | | | Summary: Added support for Type Alias declarations. Reviewers: alexfh Subscribers: cfe-commits Patch by James Reynolds! Differential Revision: http://reviews.llvm.org/D20856 llvm-svn: 271992
* [clang-tidy] Ignore the deleted function in misc-definitions-in-headers.Haojian Wu2016-06-071-6/+8
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21059 llvm-svn: 271991
* [clang-tidy] Do not try to suggest a fix if the parameter is partially in a ↵Samuel Benzaquen2016-06-061-0/+6
| | | | | | | | | macro. It is not easy to tell where to do the suggestion and whether the suggestion will be correct. llvm-svn: 271896
* [clang-tidy] modernize-use-auto: don't remove stars by defaultAlexander Kornienko2016-06-032-22/+36
| | | | | | | | | | | | | | | Summary: By default, modernize-use-auto check will retain stars when replacing an explicit type with `auto`: `MyType *t = new MyType;` will be changed to `auto *t = new MyType;`, thus resulting in more consistency with the recommendations to use `auto *` for iterating over pointers in range-based for loops: http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto The new `RemoveStars` option allows to revert to the old behavior: with the new option turned on the check will change `MyType *t = new MyType;` to `auto t = new MyType;`. Reviewers: aaron.ballman, sbenza Subscribers: Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D20917 llvm-svn: 271739
* [clang-tidy] Ignore function context in misc-unused-using-decls.Haojian Wu2016-06-032-5/+20
| | | | | | | | | | | | Summary: Make the check's behavior more correct when handling using-decls in multiple scopes. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20909 llvm-svn: 271632
* Fix uninitialized memory access when the token 'const' is not present inSamuel Benzaquen2016-06-011-5/+8
| | | | | | | | | the program. If the token is not there, we still warn but we don't try to give a fixit hint. llvm-svn: 271426
* [ASTMatchers] Added ignoringParenImpCasts to has matchersPiotr Padlewski2016-05-3122-116/+137
| | | | | | | | | has matcher changed behaviour, and now it matches "as is" and doesn't skip implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271289
* [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const ↵Felix Berger2016-05-312-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | "this" object argument if it is not modified. Summary: Also trigger the check in the following case: void foo() { ExpensiveToCopy Obj; const auto UnnecessaryCopy = Obj.constReference(); Obj.onlyUsedAsConst(); } i.e. when the object the method is called on is not const but is never modified. Reviewers: alexfh, fowles Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20010 llvm-svn: 271239
* [clang-tidy] Remove redundant quote in add_new_check scriptEtienne Bergeron2016-05-301-1/+1
| | | | | | | | | | | | | | Summary: Remove redundant quote. These quotes were added here: http://reviews.llvm.org/D20766 Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20792 llvm-svn: 271210
* [clang-tidy] Fix script adding new clang-tidy checkEtienne Bergeron2016-05-301-1/+1
| | | | | | | | | | | | | | Summary: The `getName()` call is useless. It's better to show a better example as tutorial. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20766 llvm-svn: 271207
* Fix a wrong check in misc-unused-using-declsHaojian Wu2016-05-301-13/+11
| | | | | | | | | | | | | | Summary: We should check whether a UsingDecl is defined in macros or in class definition, not TargetDecls of the UsingDecl. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20666 llvm-svn: 271199
* Speed up check by using a recursive visitor.Samuel Benzaquen2016-05-252-66/+84
| | | | | | | | | | | | | | | | Summary: Use a recursive visitor instead of forEachDescendant() matcher. The latter requires several layers of virtual function calls for each node and it is more expensive than the visitor. Benchmark results show improvement of ~6% walltime in clang-tidy. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20597 llvm-svn: 270714
* [clang-tidy] modernize-pass-by-value bugfixMads Ravn2016-05-241-0/+5
| | | | | | | | | | | | Modified the clang-tidy PassByValue check. It now stops adding std::move to type which is trivially copyable because that caused the clang-tidy MoveConstArg to complain and revert, thus creating a cycle. I have also added a lit-style test to verify the bugfix. This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731 This is the code review on phabricator: http://reviews.llvm.org/D20365 llvm-svn: 270565
* Commiting for http://reviews.llvm.org/D20365Mads Ravn2016-05-231-6/+0
| | | | llvm-svn: 270473
* Commiting for http://reviews.llvm.org/D20365Mads Ravn2016-05-231-0/+6
| | | | llvm-svn: 270472
* Commiting for http://reviews.llvm.org/D20365Mads Ravn2016-05-231-0/+4
| | | | llvm-svn: 270470
* [clang-tidy] Switch to a more common way of customizing check behavior.Alexander Kornienko2016-05-204-9/+9
| | | | | | | This should have been done this way from the start, however I somehow missed r257177. llvm-svn: 270215
* [clang-tidy] Handle using-decls with more than one shadow decl.Haojian Wu2016-05-202-35/+53
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits, djasper Differential Revision: http://reviews.llvm.org/D20429 llvm-svn: 270191
* [clang-tidy] Fix/add style guide links.Alexander Kornienko2016-05-191-1/+1
| | | | | | Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)! llvm-svn: 270033
* [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.Haojian Wu2016-05-181-7/+0
| | | | | | | | | | Reviewers: alexfh, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D20367 llvm-svn: 269928
* [clang-tidy] Fix a template function false positive in ↵Haojian Wu2016-05-181-0/+16
| | | | | | | | | | | | | | misc-unused-using-decls check. Summary: Ignore warning uninstantiated template function usages. Reviewers: djasper, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20326 llvm-svn: 269906
* [clang-tidy] Fix a functional change from r269656.Benjamin Kramer2016-05-181-3/+4
| | | | | | | | Instead of forming char ranges that patch made us form token ranges, which behave subtly different. Sadly I'm only seeing this as part of a larger test case that I haven't fully reduced yet. llvm-svn: 269896
* [clang-tidy] Lift common matchers to utils namespaceEtienne Bergeron2016-05-176-43/+12
| | | | | | | | | | | | | | Summary: This patch is lifting matchers used by more than one checkers to the common namespace. Reviewers: aaron.ballman, alexfh Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D19841 llvm-svn: 269804
* [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)Vedant Kumar2016-05-171-0/+4
| | | | | | | | | If a use of a macro argument is preceded by the `namespace` keyword, do not warn that the use should be wrapped in parentheses. Patch by Mads Ravn! llvm-svn: 269786
* [clang-tidy] Cleanups utils filesEtienne Bergeron2016-05-169-46/+19
| | | | | | | | | | | | | | | | | | | Summary: Cleanup some code by using appropriate APIs. Some coding style cleanups. There is no behavior changes. - Function `IncludeSorter::CreateFixIt` can be replaced by `FixItHint::CreateReplacement`. - Function `cleanPath` is a wrapper for `llvm::sys::path::remove_dots`. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20279 llvm-svn: 269656
* [clang-tidy] TypeTraits - Type is not expensive to copy when it has a ↵Felix Berger2016-05-142-3/+20
| | | | | | | | | | | | deleted copy constructor. Reviewers: alexfh, sbenza Subscribers: etienneb, aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D20170 llvm-svn: 269581
* [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for ↵Felix Berger2016-05-132-20/+28
| | | | | | | | | | | | | | decl stmts with single VarDecl. Summary: This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325 Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19865 llvm-svn: 269389
* [clang-tidy] Adds modernize-avoid-bind checkJonathan Coe2016-05-124-0/+203
| | | | | | | | | | | | | | | Summary: This patch adds a check that replaces std::bind with a lambda. Not yet working for member functions. Reviewers: aaron.ballman, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16962 llvm-svn: 269341
* [clang-tidy] Ignore using-declarations defined in marcro in ↵Haojian Wu2016-05-121-0/+4
| | | | | | | | | | | | misc-unused-using-decls checks. Reviewers: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20197 llvm-svn: 269278
* [clang-tidy] Improve misc-redundant-expression and decrease false-positiveEtienne Bergeron2016-05-121-13/+96
| | | | | | | | | | | | | | | | | | Summary: This patch is adding support for conditional expression and overloaded operators. To decrease false-positive, this patch is adding a list of banned macro names that has multiple variant with same integer value. Also fixed support for template instantiation and added an unittest. Reviewers: alexfh Subscribers: klimek, Sarcasm, cfe-commits Differential Revision: http://reviews.llvm.org/D19703 llvm-svn: 269275
* [clang-tidy] Add missing dependency of libtooling to misc moduleEtienne Bergeron2016-05-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The new API for fixit is in libtooling and the library misc in clang-tidy didn't had the appropriate dependency. This commit was breaking some build bots: http://reviews.llvm.org/D19547 This commit tried (but failed) to fix it: http://reviews.llvm.org/D20180 To repro, you can make a build with these flags: ``` cmake -DBUILD_SHARED_LIBS=ON ``` Thanks rnk@ for helping figuring out. Reviewers: alexfh, rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20182 llvm-svn: 269240
* [clang-tidy] Refactoring of FixHintUtilsEtienne Bergeron2016-05-112-41/+14
| | | | | | | | | | | | | | Summary: Refactor some checkers to use the tooling re-writing API. see: http://reviews.llvm.org/D19941 Reviewers: klimek, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19807 llvm-svn: 269210
* [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.Etienne Bergeron2016-05-111-4/+12
| | | | | | | | | | | | | | | | | | Summary: Arguments can be swapped using fixit when they are not in macros. This is the same implementation than SwappedArguments. Some code got lifted to be reused. Others checks are not safe to be fixed as they tend to be bugs or errors. It is better to let the user manually review them. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19547 llvm-svn: 269208
* [clang-tidy] Adds modernize-use-bool-literals check.Jakub Staron2016-05-114-0/+94
| | | | | | Review link: http://reviews.llvm.org/D18745 llvm-svn: 269171
* [clang-tidy] Lift parsing of sequence of names functions to utils.Etienne Bergeron2016-05-106-53/+87
| | | | | | | | | | | | | | | | Summary: Lift some common code used by multiple checkers. This function is also used by checkers that are coming. It is quite common for a checker to parse a list of names. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19846 llvm-svn: 269065
* Fixed cppcoreguidelines-pro-type-member-init when checking records with ↵Haojian Wu2016-05-101-32/+30
| | | | | | | | | | | | | | | | | | indirect fields Summary: Fixed a crash in cppcoreguidelines-pro-type-member-init when checking record types with indirect fields pre-C++11. Fixed handling of indirect fields so they are properly checked and suggested fixes are proposed. Patch by Michael Miller! Reviewers: aaron.ballman, alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19993 llvm-svn: 269024
* [clang-tidy] new google-default-arguments checkHaojian Wu2016-05-094-0/+74
| | | | | | | | | | | | | | | | Summary: To check the google style guide rule here: https://google.github.io/styleguide/cppguide.html#Default_Arguments Patch by Clement Courbet! Reviewers: hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19534 llvm-svn: 268919
* Support variables and functions types in misc-unused-using-decls.Haojian Wu2016-05-092-5/+29
| | | | | | | | | | | | Summary: Fix PR27429. Reviewers: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20018 llvm-svn: 268917
* Trying to fix docs.Alexander Kornienko2016-05-092-2/+2
| | | | llvm-svn: 268905
* [clang-tidy] Apply NOLINT filtering to Clang warnings.Alexander Kornienko2016-05-041-14/+23
| | | | llvm-svn: 268555
* [clang-tidy] New: checker misc-unconventional-assign-operator replacing ↵Gabor Horvath2016-05-045-28/+42
| | | | | | | | | | | | | | misc-assign-operator-signature Summary: Finds return statements in assign operator bodies where the return value is different from '*this'. Only assignment operators with correct return value Class& are checked. Reviewers: aaron.ballman, alexfh, sbenza Subscribers: o.gyorgy, baloghadamsoftware, LegalizeAdulthood, aaron.ballman, Eugene.Zelenko, xazax.hun, cfe-commits Differential Revision: http://reviews.llvm.org/D18265 llvm-svn: 268492
OpenPOWER on IntegriCloud