summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* Use ExprMutationAnalyzer in performance-unnecessary-value-paramShuai Wang2018-08-031-34/+39
| | | | | | | | | | | | | | | | | | | | | | Summary: This yields better recall as ExprMutationAnalyzer is more accurate. One common pattern this check is now able to catch is: ``` void foo(std::vector<X> v) { for (const auto& elm : v) { // ... } } ``` Reviewers: george.karpenkov Subscribers: a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D50102 llvm-svn: 338903
* [clang-tidy] add all clang-tidy modules to pluginJonas Toth2018-07-312-11/+45
| | | | | | | | | | | | | | | | Summary: This patch addresses PR38359 and adds all existing clang-tidy modules to the plugin that can be used together with libclang. Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov Reviewed By: alexfh Subscribers: srhines, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D50060 llvm-svn: 338393
* [clang-tidy] Fix a crash in fuchsia-multiple-inheritanceIlya Biryukov2018-07-271-0/+5
| | | | | | | | | | | | | | Summary: See the test case for a repro. Reviewers: juliehockett, ioeric, hokein, aaron.ballman Reviewed By: hokein Subscribers: lebedev.ri, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D49862 llvm-svn: 338124
* [clang-tidy] Fix llvm.org/PR38315 (support type aliases in ↵Alexander Kornienko2018-07-261-2/+2
| | | | | | modernize-shrink-to-fit) llvm-svn: 338025
* [clang-tidy] fix PR36489 - respect deduced pointer types from auto as wellJonas Toth2018-07-231-2/+6
| | | | | | | | | | | | | | | | | | | | Summary: The cppcoreguidelines-pro-bounds-pointer-arithmetic warns on all occassion where pointer arithmetic is used, but does not check values where the pointer types is deduced via `auto`. This patch adjusts this behaviour and solved PR36489. I accidentally commited a wrong patch, this Differential is meant to have a correct revision description and code attached to it. Because the patch was accepted by aaron.ballman already, i will just commit it. See https://reviews.llvm.org/D48717 for the old differntial (contains wrong code from the mixup) Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D49682 llvm-svn: 337716
* [clang-tidy] remove private decltypeType in TrailingReturnTypeJonas Toth2018-07-231-2/+0
| | | | | | | | | | | | | | | | Summary: This patch removes a private matcher in fuchsia/TrailingReturnType check because the matcher is now in ASTMatchers Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D49618 llvm-svn: 337707
* [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets ↵Idriss Riouak2018-07-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | list initialization: patch Summary: Hello, i would like to suggest a fix for one of the checks in clang-tidy. The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=38039 where you can find more information. ``` struct UOB{ UOB(const UOB &Other):j{Other.j}{} int j; }; ``` In this case the check modernize-use-equals-default does not detect copy constructors that can be defaulted; that should be: ``` struct UOB{ UOB(const UOB &Other) = default; int j; }; ``` Reviewers: aaron.ballman, hokein, alexfh Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49356 llvm-svn: 337286
* [clang-tidy] Exception Escape CheckerAdam Balogh2018-07-134-0/+265
| | | | | | | | | | | Finds functions which may throw an exception directly or indirectly, but they should not: Destructors, move constructors, move assignment operators, the main() function, swap() functions, functions marked with throw() or noexcept and functions given as option to the checker. Differential Revision: https://reviews.llvm.org/D33537 llvm-svn: 336997
* [clang-tidy] readability-inconsistent-declaration-parameter-name: accept ↵Sam McCall2018-07-132-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | approximate name matches. Summary: The goal is to reduce false positives when the difference is intentional, like: foo(StringRef name); foo(StringRef name_ref) { string name = cleanup(name_ref); ... } Or semantically unimportant, like: foo(StringRef full_name); foo(StringRef name) { ... } There are other matching names we won't recognise (e.g. syns vs synonyms) but this catches many that we see in practice, and gives people a systematic workaround. The old behavior is available as a 'Strict' option. Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D49285 llvm-svn: 336992
* [clang-tidy/ObjC] Add SQL to list of acronymsBen Hamilton2018-07-121-0/+1
| | | | | | | | | | | | | | Summary: SQL is a common acronym. Reviewers: Wizard, hokein Reviewed By: Wizard, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49190 llvm-svn: 336919
* Use ExprMutationAnalyzer in performance-for-range-copyShuai Wang2018-07-101-3/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This gives better coverage to the check as ExprMutationAnalyzer is more accurate comparing to isOnlyUsedAsConst. Majority of wins come from const usage of member field, e.g.: for (auto widget : container) { // copy of loop variable if (widget.type == BUTTON) { // const usage only recognized by ExprMutationAnalyzer // ... } } Reviewers: george.karpenkov Subscribers: a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D48854 llvm-svn: 336737
* Add the cert-msc51-cpp and cert-msc32-c checks.Aaron Ballman2018-07-054-0/+177
| | | | | | | | These checks flag use of random number generators with poor seeds that would possibly lead to degraded random number generation. Patch by Borsik Gábor llvm-svn: 336301
* [clang-tidy] Fix http://llvm.org/PR38055Alexander Kornienko2018-07-041-2/+3
| | | | llvm-svn: 336283
* [clang-tidy] misc-unused-parameters - retain old behavior under StrictModeAlexander Kornienko2018-06-282-7/+22
| | | | | | | | | | | | | | Summary: This addresses https://bugs.llvm.org/show_bug.cgi?id=37467. Reviewers: klimek, ilya-biryukov, lebedev.ri, aaron.ballman Reviewed By: lebedev.ri, aaron.ballman Subscribers: aaron.ballman, lebedev.ri, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D46951 llvm-svn: 335863
* [clang-tidy/ObjC] Add hashing algorithm acronyms to objc-property-declarationBen Hamilton2018-06-271-0/+6
| | | | | | | | | | | | | | | | Summary: This PR adds a few acronyms related to hashing algorithms to the standard list in `objc-property-declaration`. Reviewers: Wizard Reviewed By: Wizard Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48652 llvm-svn: 335770
* [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression ↵Alexander Kornienko2018-06-273-0/+317
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | is mutated within a statement. Summary: (Originally started as a clang-tidy check but there's already D45444 so shifted to just adding ExprMutationAnalyzer) `ExprMutationAnalyzer` is a generally useful helper that can be used in different clang-tidy checks for checking whether a given expression is (potentially) mutated within a statement (typically the enclosing compound statement.) This is a more general and more powerful/accurate version of isOnlyUsedAsConst, which is used in ForRangeCopyCheck, UnnecessaryCopyInitialization. It should also be possible to construct checks like D45444 (suggest adding const to variable declaration) or https://bugs.llvm.org/show_bug.cgi?id=21981 (suggest adding const to member function) using this helper function. This function is tested by itself and is intended to stay generally useful instead of tied to any particular check. Reviewers: hokein, alexfh, aaron.ballman, ilya-biryukov, george.karpenkov Reviewed By: aaron.ballman Subscribers: lebedev.ri, shuaiwang, rnkovacs, hokein, alexfh, aaron.ballman, a.sidorin, Eugene.Zelenko, xazax.hun, JonasToth, klimek, mgorny, cfe-commits Tags: #clang-tools-extra Patch by Shuai Wang. Differential Revision: https://reviews.llvm.org/D45679 llvm-svn: 335736
* [clang-tidy] Remove the google-readability-redundant-smartptr-get aliasAlexander Kornienko2018-06-211-4/+0
| | | | | | | | I don't remember why I added it, but it's definitely not needed, since the check doesn't have any options and the check doesn't have any special relation to the Google C++ style. llvm-svn: 335252
* [clang-tidy] This patch is a fix for D45405 where spaces were mistakenly ↵Zinovy Nis2018-06-151-2/+33
| | | | | | | | considered as a part of a type name. So length("int *") was 5 instead of 3 with RemoveStars=0 or 4 with RemoveStars=1 Differential Revision: https://reviews.llvm.org/D45927 llvm-svn: 334829
* Reverting r334604 due to failing tests.Aaron Ballman2018-06-133-318/+0
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/31500 llvm-svn: 334606
* Add a new class to analyze whether an expression is mutated within a statement.Aaron Ballman2018-06-133-0/+318
| | | | | | | | ExprMutationAnalyzer is a generally useful helper that can be used in different clang-tidy checks for checking whether a given expression is (potentially) mutated within a statement (typically the enclosing compound statement.) This is a more general and more powerful/accurate version of isOnlyUsedAsConst, which is used in ForRangeCopyCheck, UnnecessaryCopyInitialization. Patch by Shuai Wang llvm-svn: 334604
* - Add "AV" as new default acronym. - Add support for "I" and "A" in ↵Yan Zhang2018-06-111-1/+2
| | | | | | | | | | | | | | | | lowerCamelCase pattern Summary: Now we can support property names like "hasADog" correctly. Reviewers: benhamilton, hokein Reviewed By: benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48039 llvm-svn: 334448
* Add support for arrays in performance-implicit-conversion-in-loopAlexander Kornienko2018-06-112-9/+15
| | | | | | | | | | | | | | | | | Summary: Add support for arrays (and structure that use naked pointers for their iterator, like std::array) in performance-implicit-conversion-in-loop Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits Patch by Alex Pilkiewicz. Differential Revision: https://reviews.llvm.org/D47945 llvm-svn: 334400
* [clang-tidy] Improve string type matcher for abseil-string-find-starts-with ↵Haojian Wu2018-06-081-1/+4
| | | | | | | | | | | | | | | | check. Summary: This patch improves the check to match the desugared "string" type (so that it can handle custom-implemented string classes), see the newly-added test. Reviewers: alexfh Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D47704 llvm-svn: 334270
* [checks/property-decls] Fix comment in ↵Ben Hamilton2018-06-071-1/+1
| | | | | | | | | | | | | | | | | | clang-tidy/objc/PropertyDeclarationCheck.cpp ✍️ Summary: The comment incorrectly claims that the listed acronyms are all extracted from the linked Apple documentation. Reviewers: Wizard, benhamilton Reviewed By: Wizard, benhamilton Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46922 Contributed by @stephanemoore. llvm-svn: 334238
* [clang-tidy] Store checks profiling info as JSON filesRoman Lebedev2018-06-067-51/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Continuation of D46504. Example output: ``` $ clang-tidy -enable-check-profile -store-check-profile=. -checks=-*,readability-function-size source.cpp $ # Note that there won't be timings table printed to the console. $ cat *.json { "file": "/path/to/source.cpp", "timestamp": "2018-05-16 16:13:18.717446360", "profile": { "time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00, "time.clang-tidy.readability-function-size.user": 9.2088400000005421e-01, "time.clang-tidy.readability-function-size.sys": 1.2418899999999974e-01 } } ``` There are two arguments that control profile storage: * `-store-check-profile=<prefix>` By default reports are printed in tabulated format to stderr. When this option is passed, these per-TU profiles are instead stored as JSON. If the prefix is not an absolute path, it is considered to be relative to the directory from where you have run :program:`clang-tidy`. All `.` and `..` patterns in the path are collapsed, and symlinks are resolved. Example: Let's suppose you have a source file named `example.cpp`, located in `/source` directory. * If you specify `-store-check-profile=/tmp`, then the profile will be saved to `/tmp/<timestamp>-example.cpp.json` * If you run :program:`clang-tidy` from within `/foo` directory, and specify `-store-check-profile=.`, then the profile will still be saved to `/foo/<timestamp>-example.cpp.json` Reviewers: alexfh, sbenza, george.karpenkov, NoQ, aaron.ballman Reviewed By: alexfh, george.karpenkov, aaron.ballman Subscribers: Quuxplusone, JonasToth, aaron.ballman, llvm-commits, rja, Eugene.Zelenko, xazax.hun, mgrang, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46602 llvm-svn: 334101
* [clang-tidy] new cppcoreguidelines-narrowing-conversions check.Clement Courbet2018-05-236-0/+115
| | | | | | | | | | | | | | | | | | | Summary: Checks for narrowing conversions, e.g. int i = 0; i += 0.1; This has what some might consider false positives for: i += ceil(d); Reviewers: alexfh, hokein Subscribers: srhines, nemanjai, mgorny, JDevlieghere, xazax.hun, kbarton Differential Revision: https://reviews.llvm.org/D38455 llvm-svn: 333066
* [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is ↵Zinovy Nis2018-05-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | of ExprWithCleanups type bool foo(A &S) { if (S != (A)S) return false; return true; } is fixed into (w/o this patch) ... return !S != (A)S; // negotiation affects first operand only } instead of (with this patch) ... return S == (A)S; // note == instead of != } Differential Revision: https://reviews.llvm.org/D47122 llvm-svn: 333003
* [clang-tidy] Add a flag to enable alpha checkersAlexander Kornienko2018-05-175-16/+50
| | | | | | | | | | | | | | | | Summary: The alpha checkers can already be enabled using the clang driver, this allows them to be enabled using the clang-tidy as well. This can make it easier to test the alpha checkers with projects which already support the compile_commands.json. It will also allow more people to give feedback and patches about the alpha checkers since they can run it as part of clang tidy checks. Reviewers: aaron.ballman, hokein, ilya-biryukov, alexfh, lebedev.ri, xbolva00 Reviewed By: aaron.ballman, alexfh, lebedev.ri, xbolva00 Subscribers: xbolva00, NoQ, dcoughlin, lebedev.ri, xazax.hun, cfe-commits Patch by Paul Fultz II! Differential Revision: https://reviews.llvm.org/D46159 llvm-svn: 332609
* Add a new check, readability-simplify-subscript-expr, that diagnoses array ↵Aaron Ballman2018-05-164-0/+118
| | | | | | | | | | subscript expressions that can be simplified. Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly. Patch by Shuai Wang. llvm-svn: 332519
* [clang-tidy/google-readability-casting] Disable check for Objective-C++Ben Hamilton2018-05-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, `google-readability-casting` was disabled for Objective-C. The Google Objective-C++ style allows both Objective-C and C++ style in the same file. Since clang-tidy doesn't have a good way to allow multiple styles per file, this disables the check for Objective-C++. Test Plan: New tests added. Ran tests with: % make -j16 check-clang-tools Before diff, confirmed tests failed: https://reviews.llvm.org/P8081 After diff, confirrmed tests passed. Reviewers: alexfh, Wizard, hokein, stephanemoore Reviewed By: alexfh, Wizard, stephanemoore Subscribers: stephanemoore, cfe-commits, bkramer, klimek Differential Revision: https://reviews.llvm.org/D46659 llvm-svn: 332516
* add AR to acronyms of clang-tidy property checkYan Zhang2018-05-151-0/+1
| | | | | | | | | | | | Reviewers: hokein, benhamilton Reviewed By: benhamilton Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46895 llvm-svn: 332382
* [clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-152-12/+13
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44976 llvm-svn: 332371
* [clang-tidy] Add terminating continue checkGabor Horvath2018-05-144-0/+89
| | | | | | | | Patch by: Daniel Kolozsvari! Differential Revision: https://reviews.llvm.org/D33844 llvm-svn: 332223
* Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-114-0/+170
| | | | | | This relands r332125 with a fixed test. llvm-svn: 332141
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-114-170/+0
| | | | | | This reverts commit r332125 for a failing test. llvm-svn: 332131
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-114-0/+170
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 332125
* Reland "[tools] Updating PPCallbacks::InclusionDirective calls"Julie Hockett2018-05-103-5/+10
| | | | | | | | | This commit relands r331905. r331904 added SrcMgr::CharacteristicKind to the InclusionDirective callback, this revision updates instances of it in clang-tools-extra. llvm-svn: 332023
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-094-176/+0
| | | | | | This reverts commit r331930, which was landed by accident. llvm-svn: 331934
* Revert "[tools] Updating PPCallbacks::InclusionDirective calls"Julie Hockett2018-05-093-10/+5
| | | | | | This reverts commit r331905, since it's dependent on reverted r331905. llvm-svn: 331931
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-094-0/+176
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 331930
* [tools] Updating PPCallbacks::InclusionDirective callsJulie Hockett2018-05-093-5/+10
| | | | | | | | | [revision] added SrcMgr::CharacteristicKind to the InclusionDirective callback, this revision updates instances of it in clang-tools-extra. Differential Revision: https://reviews.llvm.org/D46615 llvm-svn: 331905
* Do not warn on unused parameters for functions with empty bodies.Manuel Klimek2018-05-091-4/+5
| | | | | | If a function has an empty body, all parameters are trivially unused. llvm-svn: 331875
* Partially revert r331456: [clang-tidy] Remove AnalyzeTemporaryDtors option.Roman Lebedev2018-05-081-0/+2
| | | | | | | | | | | | | | | | | | | That broke every single .clang-tidy config out there which happened to specify AnalyzeTemporaryDtors option: YAML:5:24: error: unknown key 'AnalyzeTemporaryDtors' AnalyzeTemporaryDtors: false ^~~~~ Error parsing <...>/.clang-tidy: Invalid argument More so, that error isn't actually a error, the clang-tidy does not exit with $? != 0, it continues with the default config. Surely this breakage isn't the intended behavior. But if it is, feel free to revert this commit. llvm-svn: 331822
* Fix Wdocumentation warning. NFCI.Simon Pilgrim2018-05-081-2/+2
| | | | llvm-svn: 331805
* [clang-tidy] Profile is a per-AST (per-TU) data.Roman Lebedev2018-05-088-66/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in D45931, currently, profiling output of clang-tidy is somewhat not great. It outputs one profile at the end of the execution, and that profile contains the data from the last TU that was processed. So if the tool run on multiple TU's, the data is not accumulated, it is simply discarded. It would be nice to improve this. This differential is the first step - make this profiling info per-TU, and output it after the tool has finished processing each TU. In particular, when `ClangTidyASTConsumer` destructor runs. Next step will be to add a CSV (JSON?) printer to store said profiles under user-specified directory prefix. Reviewers: alexfh, sbenza Reviewed By: alexfh Subscribers: Eugene.Zelenko, mgorny, xazax.hun, mgrang, klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46504 llvm-svn: 331763
* Add support for ObjC property name to be a single acronym.Yan Zhang2018-05-041-0/+6
| | | | | | | | | | | | | | | | | | | | | Summary: This change will support cases like: ``` @property(assign, nonatomic) int ID; ``` Reviewers: benhamilton, hokein Reviewed By: benhamilton Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46374 llvm-svn: 331545
* [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for ↵Zinovy Nis2018-05-031-0/+12
| | | | | | | | | | | | | compatibility with clang static analyzer This macro is widely used in many well-known projects, ex. Chromium. But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered as [[no-return]], and a lot of false-positive warnings about nullptr dereferenced are emitted. Differential Revision: https://reviews.llvm.org/D46325 llvm-svn: 331474
* Add a trailing period in release notes.Alexander Kornienko2018-05-031-1/+1
| | | | llvm-svn: 331460
* [clang-tidy] Remove AnalyzeTemporaryDtors option.Alexander Kornienko2018-05-034-25/+0
| | | | | | | | Remove the `AnalyzeTemporaryDtors` option, since the corresponding `cfg-temporary-dtors` option of the Static Analyzer defaults to `true` since r326461. llvm-svn: 331456
* Update to match clang r331428.Richard Smith2018-05-032-15/+10
| | | | llvm-svn: 331429
OpenPOWER on IntegriCloud