summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Fix bug 34845, offending standard bitmask typesJonas Toth2017-10-271-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The C++ standard allows implementations to choose the underlying type for bitmask types (e.g. std::ios_base::openmode). MSVC implemented some of them as signed integers resulting in warnings for usual code like `auto dd = std::ios_base::badbit | std::ios_base::failbit;` These false positives were reported in https://bugs.llvm.org/show_bug.cgi?id=34845 The fix allows bitwise |,&,^ for known standard bitmask types under the condition that both operands are such bitmask types. Shifting and bitwise complement are still forbidden. Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: xazax.hun Differential Revision: https://reviews.llvm.org/D39099 llvm-svn: 316767
* [clang-tidy ObjC] [3/3] New check objc-forbidden-subclassingHaojian Wu2017-10-274-1/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-267-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Fix deps.NAKAMURA Takumi2017-10-212-3/+3
| | | | llvm-svn: 316260
* [clang-tidy] Don't error on MS-style inline assembly.Zachary Turner2017-10-202-0/+8
| | | | | | | | | | | To get MS-style inline assembly, we need to link in the various backends. Some other clang tools already do this, and this issue has been raised with clang-tidy several times, indicating there is sufficient desire to make this work. Differential Revision: https://reviews.llvm.org/D38549 llvm-svn: 316246
* [clang-tidy] introduce legacy resource functions to ↵Jonas Toth2017-10-182-4/+91
| | | | | | | | | | | | | | | | | | | | | | | | | '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
* Revert "Fix nested namespaces in google-readability-nested-namespace-comments."Alexander Kornienko2017-10-122-54/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts r315057. The revision introduces assertion failures: assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion() const: isExpansion() && "Not a macro expansion SLocEntry!" Stack trace: __assert_fail clang::SrcMgr::SLocEntry::getExpansion() clang::SourceManager::getExpansionLocSlowCase() clang::SourceManager::getExpansionLoc() clang::Lexer::getRawToken() clang::tidy::readability::NamespaceCommentCheck::check() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch() clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::ast_matchers::MatchFinder::matchAST() clang::MultiplexConsumer::HandleTranslationUnit() clang::ParseAST() clang::FrontendAction::Execute() clang::CompilerInstance::ExecuteAction() clang::tooling::FrontendActionFactory::runInvocation() clang::tooling::ToolInvocation::runInvocation() clang::tooling::ToolInvocation::run() Still working on an isolated test case. llvm-svn: 315580
* [clang-tidy] Use a more efficient map for the virtual near miss check.Benjamin Kramer2017-10-101-3/+3
| | | | | | DenseMap performs better here. No functionality change intended. llvm-svn: 315277
* Fix nested namespaces in google-readability-nested-namespace-comments.Aaron Ballman2017-10-062-10/+54
| | | | | | | | Fixes PR34701. Patch by Alexandru Octavian Buțiu. llvm-svn: 315057
* [clang-tidy] Emit note for variable declaration that are later deletedJonas Toth2017-10-041-4/+14
| | | | | | | | | | This patch introduces a note for variable declaration that are later deleted. Adds FIXME notes for possible automatic type-rewriting positions as well. Reviewed by aaron.ballman Differential: https://reviews.llvm.org/D38411 llvm-svn: 314913
* [clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwiseJonas Toth2017-10-031-1/+3
| | | | | | | | | | | | The bug happened with stream operations, that were not recognized in all cases. Even there were already existing test for streaming classes, they did not catch this bug. Adding the isolated example to the existing tests did not trigger the bug. Therefore i created a new isolated file that did expose the bug indeed. Differential: https://reviews.llvm.org/D38399 reviewed by aaron.ballman llvm-svn: 314808
* Fix up clang-tidy after clang r314037.Richard Smith2017-09-221-1/+4
| | | | llvm-svn: 314047
* [clang-tidy] Fixed misc-unused-parameters omitting parameters square bracketsAlexander Kornienko2017-09-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34449 **Problem:** Clang-tidy check misc-unused-parameters comments out parameter name omitting following characters (e.g. square brackets) what results in its complete removal. Compilation errors might occur after clang-tidy fix as well. **Patch description:** Changed removal range. The range should end after parameter name, not after whole parameter declarator (which might be followed by e.g. square brackets). Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Pawel Maciocha! Differential Revision: https://reviews.llvm.org/D37846 llvm-svn: 313355
* [clang-tidy] fixed misc-unused-parameters omitting parameters default valueAlexander Kornienko2017-09-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Bug: https://bugs.llvm.org/show_bug.cgi?id=34450 **Problem:** Clang-tidy check misc-unused-parameters omits parameter default value what results in its complete removal. Compilation errors might occur after clang-tidy fix. **Patch description:** Changed removal range. The range should end after parameter declarator, not after whole parameter declaration (which might contain a default value). Reviewers: alexfh, xazax.hun Reviewed By: alexfh Subscribers: JDevlieghere, cfe-commits Tags: #clang-tools-extra Patch by Pawel Maciocha! Differential Revision: https://reviews.llvm.org/D37566 llvm-svn: 313150
* [clang-tidy] Implement type-based check for `gsl::owner`Jonas Toth2017-09-125-0/+368
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-125-367/+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-125-0/+367
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] SuspiciousEnumUsageCheck bugfixPeter Szecsi2017-09-121-2/+4
| | | | | | | | | | | iThere is a reported bug on the checker not handling the some APSInt values correctly: https://bugs.llvm.org/show_bug.cgi?id=34400 This patch aims to fix it. Differential Revision: https://reviews.llvm.org/D37572 llvm-svn: 313016
* [clang-tidy] FunctionSizeCheck: wrap FunctionASTVisitor into anon namespace, NFCRoman Lebedev2017-09-111-0/+3
| | | | | | | | | | | | | This check is relatively simple, and is often being used as an example. I'm aware of at least two cases, when simply copying the FunctionASTVisitor class to a new check resulted in a rather unobvious segfault. Having it in anonymous namespace prevents such a problem. No functionality change, so i opted to avoid phabricator, especially since clang-tidy reviews are seriously jammed. llvm-svn: 312912
* [clang-tidy] add more aliases for the hicpp moduleJonas Toth2017-09-111-0/+30
| | | | | | | | 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
* Update for PrintHelpMessage not calling exit.Rafael Espindola2017-09-081-2/+2
| | | | llvm-svn: 312769
* Make run-clang-tidy compatible with Python 3.xKevin Funk2017-09-051-5/+11
| | | | | | | | | | | | | | | Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits, JDevlieghere Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D37138 Change-Id: I89a95d1e082e566e7e64c2a5ca4123c543e6b1be llvm-svn: 312532
* [cppcoreguidelines] Don't rely on SmallPtrSet iteration order.Benjamin Kramer2017-08-301-15/+14
| | | | | | | The fixit emission breaks if the iteration order changes and also missed to emit fixits for some edge cases. llvm-svn: 312166
* [clang-tidy] Improve hicpp-exception-baseclass to handle generic code betterJonas Toth2017-08-301-10/+11
| | | | | | | | | | | | | | | | Summary: This patch is a followup to the first revision D36583, that had problems with generic code and its diagnostic messages, which were found by @lebedev.ri Reviewers: alexfh, aaron.ballman, lebedev.ri, hokein Reviewed By: aaron.ballman, lebedev.ri Subscribers: klimek, sbenza, cfe-commits, JDevlieghere, lebedev.ri, xazax.hun Differential Revision: https://reviews.llvm.org/D37060 llvm-svn: 312134
* [clang-tidy] hicpp bitwise operations on signed integersJonas Toth2017-08-304-0/+96
| | | | | | | | | | | | | | | | 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] test commit for granted accessJonas Toth2017-08-301-1/+1
| | | | llvm-svn: 312102
* [clang-tidy] Fix 'misc-misplaced-widening-cast' assertion error.Daniel Marjamaki2017-08-291-0/+4
| | | | | | | | Reviewers: alexfh, xazax.hun, danielmarjamaki Differential Revision: http://reviews.llvm.org/D36670 llvm-svn: 311984
* [clang-tidy] A follow-up fix of braced-init-list constructors in make-unique ↵Haojian Wu2017-08-241-2/+14
| | | | | | | | | | | | | | check. Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D37066 llvm-svn: 311652
* [clang-tidy] bugprone-undefined-memory-manipulation: include type into the ↵Alexander Kornienko2017-08-241-7/+16
| | | | | | | | | | message Having the actual type in the message helps a lot understanding warnings in templates ;) + fix a false negative for type aliases. llvm-svn: 311651
* [clang-tidy] Add modernize-use-equals-default.IgnoreMacros optionAlexander Kornienko2017-08-172-31/+47
| | | | llvm-svn: 311136
* [clang-tidy] Ignore statements inside a template instantiation.Haojian Wu2017-08-171-2/+4
| | | | | | | | | | | | Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36822 llvm-svn: 311086
* [clang-tidy] Don't generate fixes for initializer_list constructor in ↵Haojian Wu2017-08-172-17/+38
| | | | | | | | | | | | | | | | | | | | | make_unique check. Summary: The current fix will break the compilation -- because braced list is not deducible in std::make_unique (with the use of forwarding) without specifying the type explicitly. We could support it in the future. Reviewers: alexfh Reviewed By: alexfh Subscribers: JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36786 llvm-svn: 311078
* [clang-tidy] Remove unused static variable.Chih-Hung Hsieh2017-08-161-2/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D36761 llvm-svn: 311040
* [clang-tidy] Use const char* to compile with VC cl.exe.Chih-Hung Hsieh2017-08-162-4/+4
| | | | | | | | | Summary: cl.exe does not accept constexpr char FuncBindingStr[] = ... Differential Revision: https://reviews.llvm.org/D36761 llvm-svn: 311035
* [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.Chih-Hung Hsieh2017-08-164-0/+75
| | | | | | | | | | 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-164-0/+72
| | | | | | | | | 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-164-0/+78
| | | | | | | | | 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-164-0/+85
| | | | | | | | | | 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] Use CloexecCheck as base class.Chih-Hung Hsieh2017-08-1610-158/+60
| | | | | | | | | | Summary: Simplify registerMatchers and check functions in CloexecCreatCheck, CloexecSocketCheck, CloexecFopenCheck, and CloexecOpenCheck. Differential Revision: https://reviews.llvm.org/D36761 llvm-svn: 311020
* [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.Chih-Hung Hsieh2017-08-144-0/+72
| | | | | | | | | 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-144-0/+73
| | | | | | | | | 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-146-0/+90
| | | | | | | | | Summary: dup() is better to be replaced by fcntl() to avoid file descriptor leakage. Differential Revision: https://reviews.llvm.org/D35364 llvm-svn: 310858
* Fix Wdocumentation warning - typo in argument list. NFCI.Simon Pilgrim2017-08-121-1/+1
| | | | llvm-svn: 310783
* Add hicpp-exception-baseclass to the HIC++ module.Aaron Ballman2017-08-114-0/+88
| | | | | | | | 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-111-0/+3
| | | | | | | | readability-braces-around-statements. Patch by Jonas Toth. llvm-svn: 310707
* [clang-tidy] Fix for buildbot.Yan Wang2017-08-106-0/+272
| | | | | | | | | 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-106-272/+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] Refactor the code and add a close-on-exec check on ↵Yan Wang2017-08-106-0/+272
| | | | | | | | | | | | | | | | | | | | 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-104-0/+97
| | | | | | | | Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D35932 llvm-svn: 310589
* [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors optionAlexander Kornienko2017-08-102-8/+14
| | | | llvm-svn: 310584
OpenPOWER on IntegriCloud