summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs
Commit message (Collapse)AuthorAgeFilesLines
...
* add new check to find OSSpinlock usageYan Zhang2017-11-273-0/+21
| | | | | | | | | | | | | | | | | | | | 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-tools-extra] Fix small typo in docs/ReleaseNotes.rstBen Hamilton2017-11-271-1/+1
| | | | | | | | | | | | | | | | | Summary: This is mainly a test diff to check the new Herald rule I added in LLVM Phabricator to automatically Cc: cfe-commits on all clang-tools-extra diffs. Reviewers: Wizard, hokein, klimek Reviewed By: Wizard Subscribers: dlj, bkramer, sammccall Differential Revision: https://reviews.llvm.org/D40180 llvm-svn: 319040
* [clang-tidy] Move checks from misc- to performance-Alexander Kornienko2017-11-275-19/+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] Move a few more checks from misc to bugprone.Alexander Kornienko2017-11-2412-39/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-243-4/+7
| | | | | | | | | | | | 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-233-4/+7
| | | | | | | | | | | | | | 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 misc-string-constructor bugprone-string-constructorAlexander Kornienko2017-11-233-4/+7
| | | | | | | | | | | | | | | | 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-3/+5
| | | | | | | | 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-232-6/+24
| | | | | | | | | 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-231-0/+37
| | | | | | | | | | | | 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/+10
| | | | | | | | | | 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] revert hicpp-multiway-paths-coveredJonas Toth2017-11-203-101/+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-183-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Add a check for undelegated copy of base classesGabor Horvath2017-11-173-0/+35
| | | | | | | | | | | | | | | 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-163-0/+44
| | | | | | | | | | | | | | | | 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-2/+58
| | | | | | | | | | | | | | | | | | | | | | 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] Add a note about modernize-replace-random-shuffleKrasimir Georgiev2017-11-081-0/+13
| | | | | | | | | | | | | | | | Summary: This adds a note warning the users that the way the suggested fix seeds the random number generator is poor. Reviewers: hokein Reviewed By: hokein Subscribers: cfe-commits, xazax.hun Differential Revision: https://reviews.llvm.org/D39787 llvm-svn: 317689
* [clang-tidy] Misc redundant expressions checker updated for macrosGabor Horvath2017-11-071-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-073-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Update release notes (check SVN commit-after-approval access)Ben Hamilton2017-11-021-1/+2
| | | | | | | | | | | | | | | | | | Summary: I was just granted commit-after-approval access to SVN, and @clattner recommended I try a test commit. So, this tweaks the release notes as a test. Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: Wizard Differential Revision: https://reviews.llvm.org/D39559 llvm-svn: 317261
* [clang-tidy ObjC] [3/3] New check objc-forbidden-subclassingHaojian Wu2017-10-273-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 3 of 3 of a series of changes to improve Objective-C linting in clang-tidy. This adds a new clang-tidy check `objc-forbidden-subclassing` which ensures clients do not create subclasses of Objective-C classes which are not designed to be subclassed. (Note that for code under your control, you should use __attribute__((objc_subclassing_restricted)) instead -- this is intended for third-party APIs which cannot be modified.) By default, the following classes (which are publicly documented as not supporting subclassing) are forbidden from subclassing: ABNewPersonViewController ABPeoplePickerNavigationController ABPersonViewController ABUnknownPersonViewController NSHashTable NSMapTable NSPointerArray NSPointerFunctions NSTimer UIActionSheet UIAlertView UIImagePickerController UITextInputMode UIWebView Clients can set a CheckOption `objc-forbidden-subclassing.ClassNames` to a semicolon-separated list of class names, which overrides this list. Test Plan: `ninja check-clang-tools` Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: saidinwot, Wizard, srhines, mgorny, xazax.hun Differential Revision: https://reviews.llvm.org/D39142 llvm-svn: 316744
* [clang-tidy ObjC] [1/3] New module `objc` for Objective-C checksHaojian Wu2017-10-262-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is part 1 of 3 of a series of changes to improve Objective-C linting in clang-tidy. This introduces a new clang-tidy module, `objc`, specifically for Objective-C / Objective-C++ checks. The module is currently empty; D39142 adds the first check. Test Plan: `ninja check-clang-tools` Patch by Ben Hamilton! Reviewers: hokein, alexfh Reviewed By: hokein Subscribers: Wizard, mgorny Differential Revision: https://reviews.llvm.org/D39188 llvm-svn: 316643
* [clang-tidy] introduce legacy resource functions to ↵Jonas Toth2017-10-181-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | 'cppcoreguidelines-owning-memory' Summary: This patch introduces support for legacy C-style resource functions that must obey the 'owner<>' semantics. - added legacy creators like malloc,fopen,... - added legacy consumers like free,fclose,... This helps codes that mostly benefit from owner: Legacy, C-Style code that isn't feasable to port directly to RAII but needs a step in between to identify actual resource management and just using the resources. Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: nemanjai, JDevlieghere, xazax.hun, kbarton Differential Revision: https://reviews.llvm.org/D38396 llvm-svn: 316092
* [clang-tidy] Fixed a small code example in docs. NFC.Gabor Horvath2017-10-031-1/+1
| | | | llvm-svn: 314785
* [clang-tidy] Fix example in documentation, NFCKrasimir Georgiev2017-09-221-1/+1
| | | | | | | | | | | | | | Summary: A fix in documentation. Reviewers: bkramer Reviewed By: bkramer Subscribers: JDevlieghere, xazax.hun Differential Revision: https://reviews.llvm.org/D38087 llvm-svn: 313962
* [clang-tidy] Implement type-based check for `gsl::owner`Jonas Toth2017-09-123-0/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check implements the typebased semantic of `gsl::owner`. Meaning, that - only `gsl::owner` is allowed to get `delete`d - `new` expression must be assigned to `gsl::owner` - function calls that expect `gsl::owner` as argument, must get either an owner or a newly created and recognized resource (in the moment only `new`ed memory) - assignment to `gsl::owner` must be either a resource or another owner - functions returning an `gsl::owner` are considered as factories, and their result must be assigned to an `gsl::owner` - classes that have an `gsl::owner`-member must declare a non-default destructor There are some problems that occur when typededuction is in place. For example `auto Var = function_that_returns_owner();` the type of `Var` will not be an `gsl::owner`. This case is catched, and explicitly noted. But cases like fully templated functions ``` template <typename T> void f(T t) { delete t; } // ... f(gsl::owner<int*>(new int(42))); ``` Will created false positive (the deletion is problematic), since the type deduction removes the wrapping `typeAlias`. Codereview in D36354 llvm-svn: 313067
* [clang-tidy] Revert Implement type-based check for gsl::ownerJonas Toth2017-09-123-149/+0
| | | | | | This should unbreak the buildbot for visual studio 2015 for now. llvm-svn: 313059
* [clang-tidy] Implement type-based check for `gsl::owner`Jonas Toth2017-09-123-0/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check implements the typebased semantic of `gsl::owner`. Meaning, that - only `gsl::owner` is allowed to get `delete`d - `new` expression must be assigned to `gsl::owner` - function calls that expect `gsl::owner` as argument, must get either an owner or a newly created and recognized resource (in the moment only `new`ed memory) - assignment to `gsl::owner` must be either a resource or another owner - functions returning an `gsl::owner` are considered as factories, and their result must be assigned to an `gsl::owner` - classes that have an `gsl::owner`-member must declare a non-default destructor There are some problems that occur when typededuction is in place. For example `auto Var = function_that_returns_owner();` the type of `Var` will not be an `gsl::owner`. This case is catched, and explicitly noted. But cases like fully templated functions ``` template <typename T> void f(T t) { delete t; } // ... f(gsl::owner<int*>(new int(42))); ``` Will created false positive (the deletion is problematic), since the type deduction removes the wrapping `typeAlias`. Please give your comments :) llvm-svn: 313043
* [clang-tidy] add more aliases for the hicpp moduleJonas Toth2017-09-1113-2/+128
| | | | | | | | This patch will introduce even more aliases for the hicpp-module to already existing checks and is a follow up for D30383 finishing the other sections. It fixes a forgotten highlight in hicpp-braces-around-statements.rst, too. llvm-svn: 312901
* [clang-tidy] hicpp bitwise operations on signed integersJonas Toth2017-08-303-0/+16
| | | | | | | | | | | | | | | | Summary: This check implements the rule [[ http://www.codingstandard.com/section/5-6-shift-operators/ | 5.6. HIC++ ]] that forbidds bitwise operations on signed integer types. Reviewers: aaron.ballman, hokein, alexfh, Eugene.Zelenko Reviewed By: aaron.ballman Subscribers: cfe-commits, mgorny, JDevlieghere, xazax.hun Differential Revision: https://reviews.llvm.org/D36586 llvm-svn: 312122
* [clang-tidy] Add missing IgnoreMacros doc for modernize-use-equals-default.Haojian Wu2017-08-241-0/+8
| | | | | | A followup of rL311136. llvm-svn: 311654
* [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.Chih-Hung Hsieh2017-08-163-0/+23
| | | | | | | | | | Summary: epoll_create() is better to be replaced by epoll_create1() with EPOLL_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35367 llvm-svn: 311029
* [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.Chih-Hung Hsieh2017-08-163-0/+25
| | | | | | | | | Summary: epoll_create1() is better to set EPOLL_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35365 llvm-svn: 311028
* [clang-tidy] Add a close-on-exec check on accept4() in Android module.Chih-Hung Hsieh2017-08-163-0/+25
| | | | | | | | | Summary: accept4() is better to set SOCK_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35363 llvm-svn: 311027
* [clang-tidy] Add a close-on-exec check on accept() in Android module.Chih-Hung Hsieh2017-08-163-0/+24
| | | | | | | | | | Summary: accept() is better to be replaced by accept4() with SOCK_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35362 llvm-svn: 311024
* [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.Chih-Hung Hsieh2017-08-143-0/+25
| | | | | | | | | Summary: inotify_init1() is better to set IN_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35368 llvm-svn: 310863
* [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.Chih-Hung Hsieh2017-08-143-0/+23
| | | | | | | | | Summary: inotify_init() is better to be replaced by inotify_init1() with IN_CLOEXEC flag to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35370 llvm-svn: 310861
* [clang-tidy] Add a close-on-exec check on dup() in Android module.Chih-Hung Hsieh2017-08-143-0/+24
| | | | | | | | | Summary: dup() is better to be replaced by fcntl() to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35364 llvm-svn: 310858
* Add hicpp-exception-baseclass to the HIC++ module.Aaron Ballman2017-08-113-0/+37
| | | | | | | | This enforces that throwing an exception in C++ requires that exception to inherit from std::exception. Patch by Jonas Toth. llvm-svn: 310727
* Implement hicpp-braces-around-statements as an alias to ↵Aaron Ballman2017-08-113-0/+14
| | | | | | | | readability-braces-around-statements. Patch by Jonas Toth. llvm-svn: 310707
* [clang-tidy] Fix for buildbot.Yan Wang2017-08-103-0/+25
| | | | | | | | | Summary: Fix an issue for windows. Differential Revision: https://reviews.llvm.org/D35372 llvm-svn: 310669
* Revert "[clang-tidy] Refactor the code and add a close-on-exec check on ↵Reid Kleckner2017-08-103-25/+0
| | | | | | | | | | | | memfd_create() in Android module." This reverts commit r310630. The new code broke on Windows and was untested. On Linux, it was selecting the "int" overload of operator<<, which definitely does not print the right thing when fed a "Mode" char. llvm-svn: 310661
* [clang-tidy] Fix a buildbot.Yan Wang2017-08-101-2/+2
| | | | | | Fix format in ReleaseNotes.rst. llvm-svn: 310643
* [clang-tidy] Refactor the code and add a close-on-exec check on ↵Yan Wang2017-08-103-0/+25
| | | | | | | | | | | | | | | | | | | | memfd_create() in Android module. Summary: 1. Refactor the structure of the code by adding a base class for all close-on-exec checks, which implements most of the needed functions. 2. memfd_create() is better to set MFD_CLOEXEC flag to avoid file descriptor leakage. Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh, hokein Subscribers: Eugene.Zelenko, chh, cfe-commits, srhines, mgorny, JDevlieghere, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D35372 llvm-svn: 310630
* [clang-tidy] Add integer division checkGabor Horvath2017-08-103-0/+46
| | | | | | | | Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D35932 llvm-svn: 310589
* [clang-tidy] Updated docs and release notes for r310584Alexander Kornienko2017-08-102-4/+19
| | | | llvm-svn: 310587
* [clang-tidy] Fix an error in the doc.Haojian Wu2017-08-101-1/+2
| | | | llvm-svn: 310578
* [clang-tidy] add forwarders in the aliased checks from hicpp moduleHaojian Wu2017-08-1013-24/+48
| | | | | | | | | | | | | | | | Summary: Adds redirections notes and the actual redirections in the documentation for hicpp Patch by: Jonas Toth Reviewers: aaron.ballman, hokein, alexfh Reviewed By: aaron.ballman, hokein Subscribers: JDevlieghere, xazax.hun Differential Revision: https://reviews.llvm.org/D36355 llvm-svn: 310577
* [clang-tidy] Minor documentation improvementGabor Horvath2017-08-101-0/+1
| | | | | | Patch by: Lilla Barancsuk llvm-svn: 310559
* [clang-tidy] Add missing doc in ↵Haojian Wu2017-08-102-0/+10
| | | | | | cppcoreguidelines-c-copy-assignment-signature check. llvm-svn: 310558
OpenPOWER on IntegriCloud