summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy]: Google: new check 'google-upgrade-googletest-case'Eric Fiselier2019-07-291-0/+3
| | | | | | | | | | | Introduce a new check to upgrade user code based on API changes in Googletest. The check finds uses of old Googletest APIs with "case" in their name and replaces them with the new APIs named with "suite". Patch by Alex Strelnikov (strel@google.com) Reviewed as D62977. llvm-svn: 367263
* [clang-tidy] New check calling out uses of +new in Objective-C codeDmitri Gribenko2019-05-231-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Google's Objective-C style guide forbids calling or overriding +new to instantiate objects. This check warns on violations. Style guide reference: https://google.github.io/styleguide/objcguide.html#do-not-use-new Patch by Michael Wyman. Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, stephanemoore, mwyman Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman Subscribers: stephanemoore, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D61350 llvm-svn: 361487
* [clang-tidy] Add check for underscores in googletest names.Haojian Wu2019-01-251-0/+4
| | | | | | | | | | | | | | | | | | Summary: Adds a clang-tidy warning for underscores in googletest names. Patch by Kar Epker! Reviewers: hokein, alexfh, aaron.ballman Reviewed By: hokein Subscribers: Eugene.Zelenko, JonasToth, MyDeveloperDay, lebedev.ri, xazax.hun, mgorny, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D56424 llvm-svn: 352183
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy/checks] Implement a clang-tidy check to verify Google ↵Stephane Moore2018-11-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Objective-C function naming conventions 📜 Summary: §1 Description This check finds function names in function declarations in Objective-C files that do not follow the naming pattern described in the Google Objective-C Style Guide. Function names should be in UpperCamelCase and functions that are not of static storage class should have an appropriate prefix as described in the Google Objective-C Style Guide. The function `main` is a notable exception. Function declarations in expansions in system headers are ignored. Example conforming function definitions: ``` static bool IsPositive(int i) { return i > 0; } static bool ABIsPositive(int i) { return i > 0; } bool ABIsNegative(int i) { return i < 0; } ``` A fixit hint is generated for functions of static storage class but otherwise the check does not generate a fixit hint because an appropriate prefix for the function cannot be determined. §2 Test Notes * Verified clang-tidy tests pass successfully. * Used check_clang_tidy.py to verify expected output of processing google-objc-function-naming.m Reviewers: benhamilton, hokein, Wizard, aaron.ballman Reviewed By: benhamilton Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51575 llvm-svn: 347132
* [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] Remove google-runtime-member-string-referencesBenjamin Kramer2018-04-051-3/+0
| | | | | | | | | | This is triggering on a pattern that's both too broad (const std::string& members can be used safely) and too narrow (std::string is not the only class with this problem). It has a very low true positive rate, just remove it until we find a better solution for dangling string references. llvm-svn: 329292
* add check to avoid throwing objc exception according to Google Objective-C guideYan Zhang2017-11-161-0/+3
| | | | | | | | | | | | | | | | 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 in google module for Objective-C code to ensure global ↵Haojian Wu2017-11-071-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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] Add bugprone-suspicious-memset-usage checkGabor Horvath2017-07-141-3/+0
| | | | | | | | | | | | | | | | | | Created new module bugprone and placed the check in that. Finds memset() calls with potential mistakes in their arguments. Replaces and extends the existing google-runtime-memset-zero-length check. Cases covered: * Fill value is a character '0'. Integer 0 might have been intended. * Fill value is out of char range and gets truncated. * Byte count is zero. Potentially swapped with the fill value argument. Patch by: Reka Nikolett Kovacs Differential Revision: https://reviews.llvm.org/D32700 llvm-svn: 308020
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-1/+1
| | | | | | | | | | | | | | | | Summary: Ran clang-format on all .c/.cpp/.h files in clang-tools-extra. Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories. Reviewers: klimek, alexfh Subscribers: nemanjai Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D26329 llvm-svn: 286221
* [clang-tidy] new google-default-arguments checkHaojian Wu2016-05-091-0/+3
| | | | | | | | | | | | | | | | Summary: To check the google style guide rule here: https://google.github.io/styleguide/cppguide.html#Default_Arguments Patch by Clement Courbet! Reviewers: hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19534 llvm-svn: 268919
* [clang-tidy] Add non-constant references in function parameters check.Alexander Kornienko2016-02-021-0/+3
| | | | | | | | | | | | | | | Summary: This is implemented originally by Alexander Kornienko. Reviewers: alexfh Subscribers: cfe-commits Patch by Haojian Wu! Differential Revision: http://reviews.llvm.org/D16717 llvm-svn: 259530
* [clang-tidy] Move google-readability-function check to ↵Alexander Kornienko2015-03-161-3/+0
| | | | | | | | | | | | | | | | readability-named-parameter. Summary: The relevant style rule is going to be removed, thus the check is no longer needed in the Google module. Leaving the check in readability/ in case someone needs it. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D8261 llvm-svn: 232431
* [clang-tidy] Refactor: Rename clang-tidy readability check files and classes ↵Alexander Kornienko2015-03-091-3/+3
| | | | | | | | | | | | | to follow naming conventions Classes are named WhateverCheck, files are WhateverCheck.cpp and` WhateverCheck.h` http://reviews.llvm.org/D8144 Patch by Richard Thomson! llvm-svn: 231650
* [clang-tidy] Refactor: Move google clang-tidy checks to namespace ↵Alexander Kornienko2015-03-051-7/+13
| | | | | | | | | | clang::tidy::google http://reviews.llvm.org/D7994 Patch by Richard Thomson! llvm-svn: 231364
* Add clang-tidy check google-global-names-in-headers.Samuel Benzaquen2015-02-111-0/+3
| | | | | | | | | | | | | | Summary: google-global-names-in-headers flags global namespace pollution in header files. Right now it only triggers on using declarations and directives. Reviewers: alexfh Subscribers: curdeius Differential Revision: http://reviews.llvm.org/D7563 llvm-svn: 228875
* [cleanup] Re-sort the #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-4/+4
| | | | | | | No functionality changed, this is just a mechanical cleanup to keep the order of #include lines consistent across the project. llvm-svn: 225976
* [clang-tidy] Set google-readability-namespace-comments.ShortNamespaceLines to 10Alexander Kornienko2014-11-201-1/+1
| | | | | | This value is used in cpplint, so we'd better be consistent. llvm-svn: 222431
* [clang-tidy] Bring order to check registration.Alexander Kornienko2014-10-261-2/+9
| | | | | | | | | | | | | | | | Summary: Register readability checks in a separate module. Renamed the checks and test file names accordingly. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5936 llvm-svn: 220631
* [clang-tidy] Default options in modules.Alexander Kornienko2014-10-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch allows modules to specify default options for the checks defined in them. This way a sufficiently configurable check can be registered in multiple modules with different default options. E.g. the SpacesBeforeComments option may be set to 1 for the "llvm-namespace-comments" check and to 2 for the "google-readability-namespace-comment" check without modifying or extending the check code. This patch also registers the google-readability-braces-around-statements check with suitable defaults. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5798 llvm-svn: 219923
* Add NamespaceCommentCheck to the Google module.Alexander Kornienko2014-09-221-0/+3
| | | | | | | | | | | | | | | | | Summary: This uses a bit hacky way to set the defaults for the spaces before comments, but it's also one of the simplest ways. Fixed a bug with how the SpacesBeforeComments option was used. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5410 llvm-svn: 218240
* [clang-tidy] Add a checker that warns on TODO comments without username.Benjamin Kramer2014-09-181-0/+3
| | | | | | | | | It also suggests a fix-it, taking the name from $USER. This will be made configurable eventually. Differential Revision: http://reviews.llvm.org/D5393 llvm-svn: 218049
* Unique-ptrify ClangTidyCheckFactories. Add a more convenient alternative toAlexander Kornienko2014-09-101-30/+20
| | | | | | | | | | | | | | addCheckFactory: registerCheck. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5288 llvm-svn: 217489
* [clang-tidy] Add a checker that suggests replacing short/long/long long with ↵Benjamin Kramer2014-08-291-0/+4
| | | | | | | | fixed-size types. Differential Revision: http://reviews.llvm.org/D5119 llvm-svn: 216726
* [clang-tidy] Add a checker for zero-length memset.Benjamin Kramer2014-07-161-0/+4
| | | | | | | | | | | | If there's memset(x, y, 0) in the code it's most likely a mistake. The checker suggests a fix-it to swap 'y' and '0'. I think this has the potential to be promoted into a general clang warning after some testing in clang-tidy. Differential Revision: http://reviews.llvm.org/D4535 llvm-svn: 213155
* [clang-tidy] Add namespaces checkers.Benjamin Kramer2014-07-161-0/+8
| | | | | | | | | | This change contains of two checkers that warn about 1. anonymous namespaces in header files. 2. 'using namespace' directives everywhere. Differential Revision: http://reviews.llvm.org/D4523 llvm-svn: 213153
* [clang-tidy] Add a checker that warns on const string & members.Benjamin Kramer2014-07-161-0/+4
| | | | | | | | | | | | | | Summary: Those are considered unsafe and should be replaced with simple pointers or full copies. It recognizes both std::string and ::string. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4522 llvm-svn: 213133
* [clang-tidy] Add a checker that flags unnamed parameters.Benjamin Kramer2014-07-151-0/+4
| | | | | | | | | | | | | | | | Summary: We still allow the escape hatch foo(int /*x*/) and also suggest this in a fixit. This is more powerful than the corresponding cpplint.py check it also flags functions with multiple arguments as naming all arguments is recommended by the google style guide. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4518 llvm-svn: 213075
* [clang-tidy] Add a checker that flags all instances of overloaded unary ↵Benjamin Kramer2014-07-151-0/+4
| | | | | | | | | | operator& This handles both methods and freestanding overloads. Differential Revision: http://reviews.llvm.org/D4498 llvm-svn: 213067
* [clang-tidy] Add a checker that removes deducible arguments from std::make_pairBenjamin Kramer2014-07-151-0/+4
| | | | | | | | | | | Those may be incompatible with C++11 and are unnecessary. We suggest removing the template arguments when they match the types of the make_pair arguments or replace it with std::pair and explicit template arguments when not. Differential Revision: http://reviews.llvm.org/D4497 llvm-svn: 213058
* Another attempt to add a clang-tidy check for flagging C-style casts.Alexander Kornienko2014-06-291-0/+4
| | | | | | | | | | | | | | | | | | | Summary: The first version failed the SubstNonTypeTempateParmExpr-related test on some buildbots. This one uses the new substNonTypeTempateParmExpr matcher to filter out implicit C-style casts. This patch depends on D4327. Reviewers: djasper Reviewed By: djasper Subscribers: aemerson, cfe-commits Differential Revision: http://reviews.llvm.org/D4328 llvm-svn: 212002
* Rolling back, as the test fails on one of the buildbots:Alexander Kornienko2014-06-251-4/+0
| | | | | | http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/13505/steps/check-all/logs/Clang%20Tools%3A%3Ac-style-casts.cpp llvm-svn: 211708
* Add a check to flag the usage of C-style casts (Google Style).Alexander Kornienko2014-06-251-0/+4
| | | | | | | | | | | | | | | | | Summary: Add a check to flag the usage of C-style casts, as per Google Style Guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4189 llvm-svn: 211702
* Move google-explicit-constructor check to a separate source file.Alexander Kornienko2014-06-181-72/+1
| | | | | | | | | | | | | | Summary: No functional changes. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4188 llvm-svn: 211154
* Track clang changes from r209061Alp Toker2014-05-171-2/+1
| | | | llvm-svn: 209062
* Fix assertion in google-explicit-constructor check when the constructor isAlexander Kornienko2014-05-051-3/+5
| | | | | | | | | | | | | | | | | | defined in a macro. Summary: We shouldn't suggest replacements in macros anyway, as we can't see all usages of the macro and ensure the replacement is safe for all of them. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3611 llvm-svn: 207987
* Fix the message for "Move constructor declared explicit".Alexander Kornienko2014-04-291-1/+2
| | | | | | Make the tests for removal of 'explicit' more diverse. llvm-svn: 207534
* Warn on explicit copy constructors.Alexander Kornienko2014-04-291-3/+46
| | | | | | | | | | | | | | | | | Summary: The Google C++ Style Guide doesn't require copy constructors to be declared explicit, but some people do this by mistake. Make this check detect and fix such cases. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3541 llvm-svn: 207531
* clang-tidy explicit constructor check: don't warn on copy or move constructors.Alexander Kornienko2014-03-201-1/+1
| | | | | | | | | | | | | | | | | Summary: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors "The exception is copy constructors, which, in the rare cases when we allow them, should probably not be explicit." Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3122 llvm-svn: 204322
* clang-tidy explicit constructors check: don't warn on deleted constructors.Alexander Kornienko2014-03-191-1/+2
| | | | | | | | | | | | Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3116 llvm-svn: 204226
* Fixed formatting.Alexander Kornienko2014-03-051-2/+1
| | | | llvm-svn: 202969
* [C++11] Replace LLVM_OVERRIDE with 'override'Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202632
* Normalized "virtual" and "LLVM_OVERRIDE" usage in clang-tidy.Alexander Kornienko2014-02-271-1/+2
| | | | | | | | | | | | Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2894 llvm-svn: 202392
* Fix ExplicitConstructorCheck to warn only on in-class declarations.Alexander Kornienko2014-02-131-10/+12
| | | | | | | | | | | | | | | | Summary: I'm not absolutely sure this is 100% correct solution, but it seems to do what I expect. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2756 llvm-svn: 201308
* Add the check name to the clang-tidy diagnostic output.Alexander Kornienko2014-01-131-1/+1
| | | | | | | | | | | | | | | | | Summary: Pass check names all the way from ClangTidyModule through ClangTidyCheck and ClangTidyContext to ClangTidyError, and output it in handleErrors. This allows to find mis-behaving check and disable it easily. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2534 llvm-svn: 199094
* Run llvm/utils/sort_includes.py over the Clang tools code. This doesn'tChandler Carruth2014-01-071-2/+2
| | | | | | | | | | always produce as pretty of results as it does in LLVM and Clang, but I don't mind and the value of having a single canonical ordering is very high IMO. Let me know if you spot really serious problems here. llvm-svn: 198703
* Initial architecture for clang-tidy.Daniel Jasper2013-07-291-0/+61
This is the first version of a possible clang-tidy architecture. The purpose of clang-tidy is to detect errors in adhering to common coding patterns, e.g. described in the LLVM Coding Standards. This is still heavily in flux. Review: http://llvm-reviews.chandlerc.com/D884 llvm-svn: 187345
OpenPOWER on IntegriCloud