summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Avoid fuchsia-overloaded-operator false positive with lambdas ↵Sam McCall2019-01-161-0/+2
| | | | | | after r351047 llvm-svn: 351307
* [clang-tidy] Treat references to smart pointers correctly in use-after-move.Martin Bohme2019-01-161-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Previously, we weren't recognizing these as smart pointers and thus weren't allowing non-dereference accesses as we should -- see new test cases which fail without the fix. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D56585 llvm-svn: 351303
* [clang-tidy] update FunctionSizeCheck for D56444Sam McCall2019-01-141-1/+6
| | | | | | | | | | Reviewers: JonasToth, aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D56552 llvm-svn: 351048
* [clang-tidy] new check 'readability-redundant-preprocessor'Miklos Vajna2019-01-114-0/+148
| | | | | | | | | | Finds potentially redundant preprocessor directives. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D54349 llvm-svn: 350922
* Adapt to CXXMethodDecl::getThisType change (NFC)Brian Gesiak2019-01-111-3/+1
| | | | | | | | | Summary: https://reviews.llvm.org/D56509 changed the API of the CXXMethodDecl::getThisType method. Adapt to the change (and re-apply clang-format) to fix the clang-tidy build. llvm-svn: 350916
* [clang-tidy] Fix case of local variables in modernize-use-nodiscard checkerJonas Toth2019-01-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Correct the case of the local variables.. Rational: I want to be able to run clang-tidy on new clang-tidy checker code prior to creating a review (to demonstrate we should dog food our own tools during development, not my suggestion but @Eugene.Zelenko) To this end I am running the following in a script, prior to make a change. ``` tidy: @for source in $$(git status -suno | grep ".cpp$$" | cut -c4-) ;\ do \ clang-tidy -quiet $$source -- $(TIDY_FLAGS);\ done ``` I then want to go through the checkers and see which checkers most closely match the review style of the reviewers ``` --- Checks: ' -clang-diagnostic-*, readability-identifier-naming, llvm-header-guard ' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: LLVM CheckOptions: - key: readability-identifier-naming.IgnoreFailedSplit value: '0' - key: readability-identifier-naming.VariableCase value: 'CamelCase' - key: readability-identifier-naming.LocalVariableCase value: 'CamelCase' ... ``` Unfortunately in doing so, I have identified that my previous review {D55433} it violates what looks like to be the convention of local variables being in CamelCase. Sending this small review in the hope it can be corrected. Patch by MyDeveloperDay. Reviewers: JonasToth, Eugene.Zelenko Reviewed By: JonasToth Subscribers: xazax.hun, Eugene.Zelenko Differential Revision: https://reviews.llvm.org/D56536 llvm-svn: 350814
* [clang-tidy] Adding a new modernize use nodiscard checkerJonas Toth2019-01-094-0/+199
| | | | | | | | | | | | | | | | | | Summary: Adds a checker to clang-tidy to warn when a non void const member function, taking only parameters passed by value or const reference could be marked as '[[nodiscard]]' Patch by MyDeveloperDay. Reviewers: alexfh, stephenkelly, curdeius, aaron.ballman, hokein, JonasToth Reviewed By: curdeius, JonasToth Subscribers: Eugene.Zelenko, lefticus, lebedev.ri, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55433 llvm-svn: 350760
* [clang-tidy] Use the public hasInit matcher, rather than defining our own, NFCHyrum Wright2019-01-071-21/+7
| | | | llvm-svn: 350526
* [clang-tidy] Export the abseil duration inverse lookup function, NFCHyrum Wright2018-12-282-2/+7
| | | | | | This allows other tools to use this function. llvm-svn: 350133
* [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffixMiklos Vajna2018-12-242-1/+6
| | | | | | | | | | | | | | And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth, lebedev.ri Differential Revision: https://reviews.llvm.org/D56025 llvm-svn: 350056
* [clang-tidy] Be more liberal about literal zeroes in abseil checksHyrum Wright2018-12-212-6/+40
| | | | | | | | | Summary: Previously, we'd only match on literal floating or integral zeroes, but I've now also learned that some users spell that value as int{0} or float{0}, which also need to be matched. Differential Revision: https://reviews.llvm.org/D56012 llvm-svn: 349953
* [clang-tidy] Add export-fixes flag to clang-tidy-diffJulie Hockett2018-12-211-0/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D55848 llvm-svn: 349930
* Fix warning about unused variable [NFC]Bjorn Pettersson2018-12-211-1/+1
| | | | llvm-svn: 349891
* [clang-tidy] Use translationUnitDecl() instead of a custom matcher.Alexander Kornienko2018-12-202-18/+5
| | | | llvm-svn: 349758
* [clang-tidy] Diagnose abseil-duration-comparison on macro argumentsHyrum Wright2018-12-194-20/+31
| | | | | | | | | | | | Summary: This change relaxes the requirements on the utility `rewriteExprFromNumberToDuration` function, and introduces new checking inside of the `abseil-duration-comparison` check to allow macro argument expression transformation. Differential Revision: https://reviews.llvm.org/D55784 llvm-svn: 349636
* [clang-tidy] use "const SourceManager&" parameter, NFC.Haojian Wu2018-12-191-3/+3
| | | | llvm-svn: 349623
* [clang-tidy] Remove extra config.h includesIvan Donchevskii2018-12-142-2/+0
| | | | | | | | | It's included in a new header ClangTidyForceLinker.h and should not be included the second time. Follow up for the https://reviews.llvm.org/D55595 llvm-svn: 349132
* [clang-tidy] Share the forced linking code between clang-tidy tool and pluginIvan Donchevskii2018-12-143-185/+116
| | | | | | | | | Extract code that forces linking to the separate header and include it in both plugin and standalone tool. Try 2: missing header guard and "clang/Config/config.h" are added to the new header. Differential Revision: https://reviews.llvm.org/D55595 llvm-svn: 349131
* [clang-tidy] Improve google-objc-function-naming diagnostics 📙Stephane Moore2018-12-141-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The diagnostics from google-objc-function-naming check will be more actionable if they provide a brief description of the requirements from the Google Objective-C style guide. The more descriptive diagnostics may help clarify that functions in the global namespace must have an appropriate prefix followed by Pascal case (engineers working previously with static functions might not immediately understand the different requirements of static and non-static functions). Test Notes: Verified against the clang-tidy tests. Reviewers: benhamilton, aaron.ballman Reviewed By: benhamilton Subscribers: MyDeveloperDay, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D55482 llvm-svn: 349123
* Revert "[clang-tidy] Share the forced linking code between clang-tidy tool ↵Douglas Yung2018-12-143-110/+185
| | | | | | | | | | | and plugin" This reverts commit r349038 as it was causing test failures: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/22185 http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/40886 llvm-svn: 349121
* [clang-tidy] Add the abseil-duration-subtraction checkHyrum Wright2018-12-137-116/+215
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This check uses the context of a subtraction expression as well as knowledge about the Abseil Time types, to infer the type of the second operand of some subtraction expressions in Duration conversions. For example: absl::ToDoubleSeconds(duration) - foo can become absl::ToDoubleSeconds(duration - absl::Seconds(foo)) This ensures that time calculations are done in the proper domain, and also makes it easier to further deduce the types of the second operands to these expressions. Reviewed By: JonasToth Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55245 llvm-svn: 349073
* [clang-tidy] Share the forced linking code between clang-tidy tool and pluginIvan Donchevskii2018-12-133-185/+110
| | | | | | | | Extract code that forces linking to the separate header and include it in both plugin and standalone tool Differential Revision: https://reviews.llvm.org/D55595 llvm-svn: 349038
* Add explicit dependency on clangSerialization after rC348911Fangrui Song2018-12-124-0/+4
| | | | llvm-svn: 348916
* Use the standard Duration factory matcherJonas Toth2018-12-111-4/+2
| | | | | | | | | | | | | | | | | | Summary: A new check came in over the weekend; it should use our existing infrastructure for matching `absl::Duration` factories. Patch by hwright. Reviewers: JonasToth Reviewed By: JonasToth Subscribers: astrelni Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55541 llvm-svn: 348842
* [clang-tidy] insert release notes for new checkers alphabeticallyJonas Toth2018-12-101-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Almost all code review comments on new checkers {D55433} {D48866} {D54349} seem to ask for the release notes to be added alphabetically, plus I've seen commits by @Eugene.Zelenko reordering the lists Make add_new_check.py add those release notes alphabetically based on checker name If include-fixer section is seen add it at the end Minor change in the message format to prevent double newlines added before the checker. Do the tools themselves have unit tests? (sorry new to this game) - Tested adding new checker at the beginning - Tested on adding new checker in the middle - Tested on empty ReleasesNotes.rst (as we would see after RC) Patch by MyDeveloperDay. Reviewers: alexfh, JonasToth, curdeius, aaron.ballman, benhamilton, hokein Reviewed By: JonasToth Subscribers: cfe-commits, xazax.hun, Eugene.Zelenko Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55508 llvm-svn: 348793
* [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'Eric Fiselier2018-12-074-0/+202
| | | | | | | | | | | | | Patch by Alex Strelnikov. Reviewed as D53830 Introduce a new check to upgrade user code based on upcoming API breaking changes to absl::Duration. The check finds calls to arithmetic operators and factory functions for absl::Duration that rely on an implicit user defined conversion to int64_t. These cases will no longer compile after proposed changes are released. Suggested fixes explicitly cast the argument int64_t. llvm-svn: 348633
* [clang-tidy] Remove duplicated getText implementation, NFCHaojian Wu2018-12-071-11/+7
| | | | llvm-svn: 348583
* Revert "[clang-tidy] new check: bugprone-branch-clone"Jonas Toth2018-12-054-258/+0
| | | | | | | The patch broke on buildbot with assertion-failure. Revert until this is figured out. llvm-svn: 348344
* [clang-tidy] new check: bugprone-branch-cloneJonas Toth2018-12-054-0/+258
| | | | | | | | | | | | | | | | | | | | | | Summary: 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 donat.nagy. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: MTC, lebedev.ri, whisperity, xazax.hun, Eugene.Zelenko, mgorny, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D54757 llvm-svn: 348343
* Fix a false positive in misplaced-widening-castJonas Toth2018-12-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: bugprone-misplaced-widening-cast check used to give a false warning to the following example. enum DaysEnum{ MON = 0, TUE = 1 }; day = (DaysEnum)(day + 1); //warning: either cast from 'int' to 'DaysEnum' is ineffective... But i think int to enum cast is not widening neither ineffective. Patch by dkrupp. Reviewers: JonasToth, alexfh Reviewed By: alexfh Subscribers: rnkovacs, Szelethus, gamesh411, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55255 llvm-svn: 348341
* [clang-tidy/checks] Update objc-property-declaration check to allow ↵Stephane Moore2018-12-051-129/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arbitrary acronyms and initialisms 🔧 Summary: §1 Description This changes the objc-property-declaration check to allow arbitrary acronyms and initialisms instead of using whitelisted acronyms. In Objective-C it is relatively common to use project prefixes in property names for the purposes of disambiguation. For example, the CIColor¹ and CGColor² properties on UIColor both represent symbol prefixes being used in proeprty names outside of Apple's accepted acronyms³. The union of Apple's accepted acronyms and all symbol prefixes that might be used for disambiguation in property declarations effectively allows for any arbitrary sequence of capital alphanumeric characters to be acceptable in property declarations. This change updates the check accordingly. The test variants with custom configurations are deleted as part of this change because their configurations no longer impact behavior. The acronym configurations are currently preserved for backwards compatibility of check configuration. [1] https://developer.apple.com/documentation/uikit/uicolor/1621951-cicolor?language=objc [2] https://developer.apple.com/documentation/uikit/uicolor/1621954-cgcolor?language=objc [3] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE §2 Test Notes Changes verified by: • Running clang-tidy unit tests. • Used check_clang_tidy.py to verify expected output of processing objc-property-declaration.m Reviewers: benhamilton, Wizard Reviewed By: benhamilton Subscribers: jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51832 llvm-svn: 348331
* [clang-tidy] Ignore namespaced and C++ member functions in ↵Stephane Moore2018-12-041-2/+3
| | | | | | | | | | | | | | | | google-objc-function-naming check 🙈 Summary: The google-objc-function-naming check applies to functions that are not namespaced and should not be applied to C++ member functions. Such function declarations should be ignored by the check to avoid false positives in Objective-C++ sources. Reviewers: benhamilton, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D55101 llvm-svn: 348317
* [clang-tidy] Fix unordered_map failure with specializing std::hash<> and ↵Jonas Toth2018-12-032-2/+20
| | | | | | remove previous wrong attempt at doing so llvm-svn: 348172
* [clang-tidy] Recommit: Add the abseil-duration-comparison checkJonas Toth2018-12-038-93/+422
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration. See documentation for examples. This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks. Compilation is unbroken, because the hash-function is now directly specified for std::unordered_map, as 'enum class' does not compile as key (seamingly only on some compilers). Patch by hwright. Reviewers: aaron.ballman, JonasToth, alexfh, hokein Reviewed By: JonasToth Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D54737 llvm-svn: 348169
* Revert "[clang-tidy] Add the abseil-duration-comparison check"Jonas Toth2018-12-038-421/+93
| | | | | | This commit broke buildbots and needs adjustments. llvm-svn: 348165
* [clang-tidy] Add the abseil-duration-comparison checkJonas Toth2018-12-038-93/+421
| | | | | | | | | | | | | | | | | | | | | Summary: This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration. See documentation for examples. This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks. Patch by hwright. Reviewers: aaron.ballman, JonasToth, alexfh, hokein Reviewed By: JonasToth Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D54737 llvm-svn: 348161
* Fix false positive with lambda assignments in cert-err58-cpp.Aaron Ballman2018-11-281-1/+2
| | | | | | This check is about preventing exceptions from being thrown before main() executes, and assigning a lambda (rather than calling it) to a global object cannot throw any exceptions. llvm-svn: 347761
* Re-commit r347419 "Update call to EvaluateAsInt() to the new syntax."Hans Wennborg2018-11-283-16/+23
| | | | llvm-svn: 347757
* Fix a false-positive with cert-err58-cpp.Aaron Ballman2018-11-281-1/+1
| | | | | | If a variable is declared constexpr then its initializer needs to be a constant expression, and thus, cannot throw. This check is about not throwing exceptions before main() runs, and so it doesn't apply if the initializer cannot throw. This silences the diagnostic when initializing a constexpr variable and fixes PR35457. llvm-svn: 347745
* [clang-tidy] Ignore bool -> single bit bitfield conversion in ↵Malcolm Parsons2018-11-271-4/+10
| | | | | | | | | | | | | | | | readability-implicit-bool-conversion Summary: There is no ambiguity / information loss in this conversion Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54941 llvm-svn: 347671
* Revert r347419 "Update call to EvaluateAsInt() to the new syntax."Hans Wennborg2018-11-273-23/+16
| | | | | | It's pre-requisite was reverted in r347656. llvm-svn: 347657
* [clang-tidy] Avoid inconsistent notes in readability-container-size-emptyAlexander Kornienko2018-11-271-0/+8
| | | | | | | | | When a warning is issued in a template instantiation, the check would previously use template arguments in a note, which would result in inconsistent or duplicate warnings (depending on how deduplication was done). This patch removes template arguments from the note. llvm-svn: 347652
* [clang-tidy] Improving narrowing conversionsGuillaume Chatelet2018-11-262-33/+476
| | | | | | | | | | | | | | | | | | | | | Summary: Newly flagged narrowing conversions: - integer to narrower signed integer (this is compiler implementation defined), - integer - floating point narrowing conversions, - floating point - integer narrowing conversions, - constants with narrowing conversions (even in ternary operator). Reviewers: hokein, alexfh, aaron.ballman, JonasToth Reviewed By: aaron.ballman, JonasToth Subscribers: lebedev.ri, courbet, nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53488 llvm-svn: 347570
* [clang-tidy] No warning for auto new expression in smart checkHaojian Wu2018-11-261-0/+3
| | | | | | | | | | | | Summary: The fix for `auto` new expression is illegal. Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54832 llvm-svn: 347551
* [clang-tidy] PrintStackTraceOnErrorSignalAlexander Kornienko2018-11-261-0/+2
| | | | llvm-svn: 347546
* [clang-tidy] Don't generate incorrect fixes for class with deleted copy ↵Haojian Wu2018-11-261-0/+13
| | | | | | | | | | | | | | | | | constructor in smart_ptr check. Summary: The fix for aggregate initialization (`std::make_unique<Foo>(Foo {1, 2})` needs to see Foo copy constructor, otherwise we will have a compiler error. So we only emit the check warning. Reviewers: JonasToth, aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54745 llvm-svn: 347537
* A bit of AST matcher cleanup, NFC.Alexander Kornienko2018-11-2527-212/+190
| | | | | | | | | Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). llvm-svn: 347520
* [clang-tidy] Ignore matches in template instantiations (cert-dcl21-cpp)Alexander Kornienko2018-11-231-1/+2
| | | | | | | | The test fails with a local modification to clang-tidy/ClangTidyDiagnosticConsumer.cpp to include fixes into the key when deduplicating the warnings. llvm-svn: 347495
* [clang-tidy] Ignore template instantiations in modernize-use-usingAlexander Kornienko2018-11-221-1/+2
| | | | | | | | | | The test I'm adding passes without the change due to the deduplication logic in ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal integration with clang-tidy. I've verified the fix by locally changing LessClangTidyError to consider replacements. llvm-svn: 347470
* Update call to EvaluateAsInt() to the new syntax.Bill Wendling2018-11-213-16/+23
| | | | llvm-svn: 347419
OpenPOWER on IntegriCloud