summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation ↵Samuel Benzaquen2018-01-081-2/+6
| | | | | | | | | | | | | | | | between basic_string and basic_string_view. Summary: Fix DanglingHandleCheck to handle the final implementation of std::string and std::string_view. These use a conversion operator instead of a conversion constructor. Reviewers: hokein Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D41779 llvm-svn: 322002
* [clang-tidy] Function-scoped static variables should not trigger ↵Ben Hamilton2018-01-051-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | google-objc-global-variable-declaration Summary: google-objc-global-variable-declaration currently triggers on valid code like: - (void)foo { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ /* ... */ }); } The Google Objective-C style guide says: http://google.github.io/styleguide/objcguide.html#common-variable-names > File scope or global variables (as opposed to constants) declared > outside the scope of a method or function should be rare, and should > have the prefix g. which is meant to insinuate that static variables inside a method or function don't need a special name. Test Plan: `make -j12 check-clang-tools` Reviewers: Wizard, hokein, klimek Reviewed By: Wizard Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D41789 llvm-svn: 321914
* clang-tidy: add IgnoreMacros option to ↵Miklos Vajna2018-01-052-1/+15
| | | | | | | | | | | | | | | | | readability-inconsistent-declaration-parameter-name 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. Reviewers: alexfh, piotrdz, hokein, ilya-biryukov Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D41716 llvm-svn: 321913
* [clang-tidy] Update fuchsia-overloaded-operator to check for valid locJulie Hockett2018-01-031-2/+6
| | | | | | | | | | | Updating fuchsia-overloaded-operator check to not issue warnings for invalid locations. Fixes PR35803. Differential Revision: https://reviews.llvm.org/D41708 llvm-svn: 321762
* [clang-tidy] Adding Fuchsia checker for overloaded operatorsJulie Hockett2017-12-224-0/+78
| | | | | | | | | | | | Adds a check to the Fuchsia module to warn if an operator is overloaded, except move and copy operators. See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for reference. Differential Revision: https://reviews.llvm.org/D41363 llvm-svn: 321363
* [clang-tidy] Misc redundant expression checker updated for ineffective ↵Gabor Horvath2017-12-201-2/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitwise operator expressions Examples: * Always evaluates to 0: ``` int X; if (0 & X) return; ``` * Always evaluates to ~0: ``` int Y; if (Y | ~0) return; ``` * The symbol is unmodified: ``` int Z; Z &= ~0; ``` Patch by: Lilla Barancsuk! Differential Revision: https://reviews.llvm.org/D39285 llvm-svn: 321168
* [clang-tidy] Adding Fuchsia checker for virtual inheritanceJulie Hockett2017-12-154-0/+80
| | | | | | | | | | | | Adds a check to the Fuchsia module to warn if classes are defined with virtual inheritance. See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for reference. Differential Revision: https://reviews.llvm.org/D40813 llvm-svn: 320841
* Add support for NOLINT and NOLINTNEXTLINE comments mentioning specific check ↵Aaron Ballman2017-12-141-8/+41
| | | | | | | | | | names. Supports a comma-separated list of check names to be disabled on the given line. Also supports * as a wildcard to disable all lint diagnostic messages on that line. Patch by Anton (xgsa). llvm-svn: 320713
* [clang-tidy] Correctly classify constant arrays and constant strings as ↵Alexander Kornienko2017-12-111-33/+31
| | | | | | | | | | | | | | | | | | | | constants when checking identifiers naming Summary: They are not locally const qualified so they weren't classified as constants by the readability-identifier-naming check. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits, xazax.hun Patch by Beren Minor! Differential Revision: https://reviews.llvm.org/D39363 llvm-svn: 320406
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* Commit access test.Julie Hockett2017-12-051-1/+1
| | | | llvm-svn: 319812
* Fix build after r319688: s/CPlusPlus1z/CPlusPlus17/Hans Wennborg2017-12-041-1/+1
| | | | llvm-svn: 319690
* add new check to find NSError init invocationYan Zhang2017-11-302-0/+0
| | | | | | | | Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D40528 llvm-svn: 319460
* add new check to find NSError init invocationYan Zhang2017-11-304-0/+77
| | | | | | | | | | | | | | | | | | | Summary: This check will find out improper initialization of NSError objects. According to Apple developer document, we should always use factory method errorWithDomain:code:userInfo: to create new NSError objects instead of [NSError alloc] init]. Otherwise it will lead to a warning message during runtime in Xcode. The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html Reviewers: hokein, benhamilton Reviewed By: benhamilton Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D40528 llvm-svn: 319459
* [clang-tidy] make readability-simplify-bool-expr completely ignore macrosAlexander Kornienko2017-11-291-4/+1
| | | | llvm-svn: 319325
* Add a new clang-tidy module for Fuchsia as an umbrella to diagnose issues ↵Aaron Ballman2017-11-287-0/+159
| | | | | | | | with the Fuschia and Zircon coding guidelines (https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md). Adds the first of such checkers, which detects when default arguments are declared in a function declaration or when default arguments are used at call sites. Patch by Julie Hockett llvm-svn: 319225
* [clang-tidy] Move more checks from misc- to performance-Alexander Kornienko2017-11-2811-52/+52
| | | | | | | | | | | | | | | | Summary: rename_check.py misc-move-const-arg performance-move-const-arg rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor Reviewers: hokein, xazax.hun Reviewed By: xazax.hun Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40507 llvm-svn: 319183
* [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throwMalcolm Parsons2017-11-281-1/+2
| | | | | | | | | | | | | | | | | Summary: The readability-else-after-return check was not warning about an else after a throw of an exception that had arguments that needed to be cleaned up. Reviewers: aaron.ballman, alexfh, djasper Reviewed By: aaron.ballman Subscribers: lebedev.ri, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40505 llvm-svn: 319174
* run-clang-tidy: Use check_call instead of check_outputKevin Funk2017-11-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Streamlines the output under Python 3.x. Before: ``` b'Enabled checks:\n clang-analyzer-apiModeling.google.GTest\n ... ``` After: ``` Enabled checks: clang-analyzer-apiModeling.google.GTest ... ``` Reviewers: cfe-commits, alexfh Reviewed By: alexfh Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D37482 Change-Id: I6287104bc73926ae6d0f66c15c250c3cb44bee33 llvm-svn: 319148
* Add an option to misc-move-const-arg to not diagnose on trivially copyable ↵Aaron Ballman2017-11-272-1/+22
| | | | | | | | types. Patch by Oleg Smolsky llvm-svn: 319111
* add new check to find OSSpinlock usageYan Zhang2017-11-274-0/+77
| | | | | | | | | | | | | | | | | | | | Summary: This check finds the use of methods related to OSSpinlock in Objective-C code, which should be deprecated due to livelock issues. The following method call will be detected: - OSSpinlockLock() - OSSpinlockTry() - OSSpinlockUnlcok() Reviewers: hokein, benhamilton Reviewed By: benhamilton Subscribers: klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D40325 llvm-svn: 319098
* [clang-tidy] Rename qualified references to check class + support ↵Alexander Kornienko2017-11-271-2/+13
| | | | | | inconsistent names llvm-svn: 319062
* [clang-tidy] Fix link error in clang-tidy after the recent check renames.Alexander Kornienko2017-11-271-0/+1
| | | | llvm-svn: 319034
* [clang-tidy] Misc redundant expressions check updated for overloaded operatorsGabor Horvath2017-11-271-17/+88
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D39243 llvm-svn: 319033
* [clang-tidy] Move checks from misc- to performance-Alexander Kornienko2017-11-279-25/+25
| | | | | | | | | | | | | | | | Summary: rename_check.py misc-move-constructor-init performance-move-constructor-init rename_check.py misc-inefficient-algorithm performance-inefficient-algorithm Reviewers: hokein, aaron.ballman Reviewed By: hokein, aaron.ballman Subscribers: aaron.ballman, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40487 llvm-svn: 319023
* [clang-tidy] readability-non-const-parameter fixes should update all ↵Alexander Kornienko2017-11-271-2/+11
| | | | | | | | declarations Fixes http://llvm.org/PR34410. llvm-svn: 319021
* [clang-tidy] Fix link error (http://llvm.org/PR35417).Alexander Kornienko2017-11-251-0/+1
| | | | llvm-svn: 318972
* [clang-tidy] Actually fix header guard handling in scriptsAlexander Kornienko2017-11-252-3/+6
| | | | llvm-svn: 318971
* [clang-tidy] rename_check.py: fix header guard handlingAlexander Kornienko2017-11-241-2/+2
| | | | llvm-svn: 318951
* [clang-tidy] Move a few more checks from misc to bugprone.Alexander Kornienko2017-11-2424-107/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang_tidy/rename_check.py misc-assert-side-effect bugprone-assert-side-effect clang_tidy/rename_check.py misc-bool-pointer-implicit-conversion bugprone-bool-pointer-implicit-conversion clang_tidy/rename_check.py misc-fold-init-type bugprone-fold-init-type clang_tidy/rename_check.py misc-forward-declaration-namespace bugprone-forward-declaration-namespace clang_tidy/rename_check.py misc-inaccurate-erase bugprone-inaccurate-erase clang_tidy/rename_check.py misc-move-forwarding-reference bugprone-move-forwarding-reference clang_tidy/rename_check.py misc-multiple-statement-macro bugprone-multiple-statement-macro clang_tidy/rename_check.py misc-use-after-move bugprone-use-after-move clang_tidy/rename_check.py misc-virtual-near-miss bugprone-virtual-near-miss Manually fixed a reference to UseAfterMoveCheck in the hicpp module. Manually fixed header guards. Reviewers: hokein Reviewed By: hokein Subscribers: nemanjai, mgorny, javed.absar, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D40426 llvm-svn: 318950
* [clang-tidy] rename_check.py misc-dangling-handle bugprone-dangling-handleAlexander Kornienko2017-11-246-11/+12
| | | | | | | | | | | | Reviewers: hokein Reviewed By: hokein Subscribers: mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40389 llvm-svn: 318941
* [clang-tidy] rename_check.py misc-argument-comment bugprone-argument-commentAlexander Kornienko2017-11-236-7/+8
| | | | | | | | | | | | | | Summary: + manually convert the unit test to lit test. Reviewers: hokein Reviewed By: hokein Subscribers: mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40392 llvm-svn: 318926
* [clang-tidy] rename_check.py: fix a bug in check presence detectionAlexander Kornienko2017-11-231-1/+1
| | | | llvm-svn: 318922
* [clang-tidy] rename_check.py: Update '=====...' line in the docs.Alexander Kornienko2017-11-231-0/+7
| | | | llvm-svn: 318918
* [clang-tidy] rename_check.py misc-string-constructor bugprone-string-constructorAlexander Kornienko2017-11-236-12/+12
| | | | | | | | | | | | | | | | Summary: Rename misc-string-constructor to bugprone-string-constructor + manually update the lenght of '==='s in the doc file. Reviewers: hokein, xazax.hun Reviewed By: hokein, xazax.hun Subscribers: mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40388 llvm-svn: 318916
* [clang-tidy] Detect bugs in bugprone-misplaced-operator-in-strlen-in-alloc ↵Adam Balogh2017-11-231-4/+17
| | | | | | | | even in the case the allocation function is called using a constant function pointer Detect bugs even if a function of the malloc() family is called using a constant pointer. llvm-svn: 318913
* [clang-tidy] Add support for operator new[] in check ↵Adam Balogh2017-11-231-2/+9
| | | | | | | | | bugprone-misplaced-operator-in-strlen-in-alloc The check now recognizes error cases like `new char[strlen(s + 1)]` and suggests a fix in the format `new char[strlen(s) + 1]`. llvm-svn: 318912
* [clang-tidy] Misplaced Operator in Strlen in AllocAdam Balogh2017-11-232-0/+129
| | | | | | | | | | | | A possible error is to write `malloc(strlen(s+1))` instead of `malloc(strlen(s)+1)`. Unfortunately the former is also valid syntactically, but allocates less memory by two bytes (if `s` is at least one character long, undefined behavior otherwise) which may result in overflow cases. This check detects such cases and also suggests the fix for them. Fix for r318906, forgot to add new files. llvm-svn: 318907
* [clang-tidy] Misplaced Operator in Strlen in AllocAdam Balogh2017-11-232-0/+4
| | | | | | | | | | A possible error is to write `malloc(strlen(s+1))` instead of `malloc(strlen(s)+1)`. Unfortunately the former is also valid syntactically, but allocates less memory by two bytes (if s` is at least one character long, undefined behavior otherwise) which may result in overflow cases. This check detects such cases and also suggests the fix for them. llvm-svn: 318906
* clang-tidy/rename_check.py: support for moving between modulesAlexander Kornienko2017-11-231-17/+160
| | | | llvm-svn: 318905
* [clang-tidy] revert hicpp-multiway-paths-coveredJonas Toth2017-11-204-234/+0
| | | | | | | | The address sanitizer found a stackoverflow with this patch. There is no obvious fix. This patch will be reapplied when the problem is found. llvm-svn: 318670
* [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branchesJonas Toth2017-11-184-0/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check searches for missing `else` branches in `if-else if`-chains and missing `default` labels in `switch` statements, that use integers as condition. It is very similar to -Wswitch, but concentrates on integers only, since enums are already covered. The option to warn for missing `else` branches is deactivated by default, since it is very noise on larger code bases. Running it on LLVM: {F5354858} for default configuration {F5354866} just for llvm/lib/Analysis/ScalarEvolution.cpp, the else-path checker is very noisy! Reviewers: alexfh, aaron.ballman, hokein Reviewed By: aaron.ballman Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits, mgorny, JDevlieghere, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D37808 llvm-svn: 318600
* [clang-tidy] Fix an oversight after renaming a checkGabor Horvath2017-11-171-1/+1
| | | | llvm-svn: 318523
* [clang-tidy] Add a check for undelegated copy of base classesGabor Horvath2017-11-174-0/+161
| | | | | | | | | | | | | | | Finds copy constructors where the constructor don't call the copy constructor of the base class. ``` class X : public Copyable { X(const X &other) {} // Copyable(other) is missing }; ``` Differential Revision: https://reviews.llvm.org/D33722 llvm-svn: 318522
* add check to avoid throwing objc exception according to Google Objective-C guideYan Zhang2017-11-164-0/+90
| | | | | | | | | | | | | | | | Summary: This is a small check to avoid throwing objc exceptions. In specific it will detect the usage of @throw statement and throw warning. Reviewers: hokein, benhamilton Reviewed By: hokein, benhamilton Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D40058 llvm-svn: 318366
* add new check for property declarationBen Hamilton2017-11-134-0/+163
| | | | | | | | | | | | | | | | | | | | | | Summary: This check finds property declarations in Objective-C files that do not follow the pattern of property names in Apple's programming guide. The property name should be in the format of Lower Camel Case or with some particular acronyms as prefix. Example: @property(nonatomic, assign) int lowerCamelCase; @property(nonatomic, strong) NSString *URLString; Test plan: ninja check-clang-tools Reviewers: benhamilton, hokein Reviewed By: hokein Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D39829 llvm-svn: 318117
* [clang-tidy] Misc redundant expressions checker updated for macrosGabor Horvath2017-11-072-75/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Redundant Expression Checker is updated to be able to detect expressions that contain macros. Also, other small details are modified to improve the current implementation. The improvements in detail are as follows: * Binary and ternary operator expressions containing two constants, with at least one of them from a macro, are detected and tested for redundancy. Macro expressions are treated somewhat differently from other expressions, because the particular values of macros can vary across builds. They can be considered correct and intentional, even if macro values equal, produce ranges that exclude each other or fully overlap, etc. * The code structure is slightly modified: typos are corrected, comments are added and some functions are renamed to improve comprehensibility, both in the checker and the test file. A few test cases are moved to another function. * The checker is now able to detect redundant CXXFunctionalCastExprs as well. A corresponding test case is added. Patch by: Lilla Barancsuk! Differential Revision: https://reviews.llvm.org/D38688 llvm-svn: 317570
* Add new check in google module for Objective-C code to ensure global ↵Haojian Wu2017-11-074-6/+139
| | | | | | | | | | | | | | | | | | | | | | | | variables follow the naming convention of Google Objective-C Style Guide Summary: This is a new checker for objc files in clang-tidy. The new check finds global variable declarations in Objective-C files that are not follow the pattern of variable names in Google's Objective-C Style Guide. All the global variables should follow the pattern of "g[A-Z].*" (variables) or "k[A-Z].*" (constants). The check will suggest a variable name that follows the pattern if it can be inferred from the original name. Patch by Yan Zhang! Reviewers: benhamilton, hokein, alexfh Reviewed By: hokein Subscribers: Eugene.Zelenko, mgorny Differential Revision: https://reviews.llvm.org/D39391 llvm-svn: 317552
* [clang-tidy] Support relative paths in run-clang-tidy.pyGabor Horvath2017-11-061-1/+8
| | | | | | | | | | Unfortunately, these python scripts are not tested currently. I did the testing manually on LLVM by editing the CMake generated compilation database to contain relative paths for some of the files. Differential Revision: https://reviews.llvm.org/D39603 llvm-svn: 317468
* [clang-tidy] Clean up installation rulesShoaib Meenai2017-11-021-5/+6
| | | | | | | | | An installation rule for the executable with the correct component is already created by `add_clang_tool`, so the rule in this file is redundant. Correct the installation component for the Python scripts so that they also get installed by `install-clang-tidy`. llvm-svn: 317155
OpenPOWER on IntegriCloud