summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Add modernize-make-shared checkPiotr Padlewski2016-05-022-0/+17
| | | | | | | | | Because modernize-make-shared do almost the same job as modernize-make-unique, I refactored common code to MakeSmartPtrCheck. http://reviews.llvm.org/D19183 llvm-svn: 268253
* Add a clang-tidy check that flags string-to-number conversion functions that ↵Aaron Ballman2016-04-292-0/+29
| | | | | | | | have insufficient error checking, suggesting a better alternative. This check corresponds to: https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number llvm-svn: 268100
* Add boost-use-to-stringPiotr Padlewski2016-04-293-1/+27
| | | | | | http://reviews.llvm.org/D18136 llvm-svn: 268079
* [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain ↵Alexander Kornienko2016-04-281-4/+4
| | | | | | | | | | | | | | | | about static variables Summary: Variables with static storage duration are zero-initialized per [stmt.dcl]p4 and [basic.start.init]p2. Reviewers: sbenza, aaron.ballman Subscribers: michael_miller, flx, cfe-commits Differential Revision: http://reviews.llvm.org/D19672 llvm-svn: 267933
* [clang-tidy] Now adding correct misc-move-const-arg documentation ;]Alexander Kornienko2016-04-261-7/+7
| | | | | | + brushed the code a bit and renamed the test file to match the check name llvm-svn: 267592
* [clang-tidy] Added misc-move-const-arg docs.Alexander Kornienko2016-04-262-1/+17
| | | | llvm-svn: 267587
* [Release notes] Mention Clang-tidy misc-fold-init-type check.Eugene Zelenko2016-04-261-4/+4
| | | | | | Highlighting consistency in Clang-tidy misc-fold-init-type check documentation. llvm-svn: 267576
* [clang-tidy] New checker for redundant expressions.Etienne Bergeron2016-04-262-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This checker finds redundant expression on both side of a binary operator. The current implementation provide a function to check whether expressions are equivalent. This implementation is able to recognize the common subset encounter in C++ program. Side-effects like "x++" are not considered to be equivalent. There are many False Positives related to macros and to floating point computations (detecting NaN). The checker is ignoring these cases. Example: ``` if( !dst || dst->depth != desired_depth || dst->nChannels != desired_num_channels || dst_size.width != src_size.width || dst_size.height != dst_size.height ) <<--- bug { ``` Reviewers: alexfh Subscribers: danielmarjamaki, fahlgren, jordan_rose, zaks.anna, Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D19451 llvm-svn: 267574
* A clang-tidy check for std:accumulate.Alexander Kornienko2016-04-262-0/+28
| | | | | | | | | | | | | | | | | Summary: For folds (e.g. std::accumulate), check matches between the provided init value and the range's value_type. A typical error is "std::accumulate(begin, end, 0);", where begin and end have float value_type. See the documentation for more examples. For now we check std::accumulate, std::reduce and std::inner_product. Reviewers: hokein, alexfh Subscribers: Prazek, aaron.ballman, cfe-commits, courbet Patch by Clément Courbet! Differential Revision: http://reviews.llvm.org/D18442 llvm-svn: 267542
* [Release Notes] Mention Clang-tidy misc-string-constructor and ↵Eugene Zelenko2016-04-211-1/+0
| | | | | | | | misc-suspicious-string-compare checks. Fix excessive line in misc-string-constructor documentation. llvm-svn: 267026
* [clang-tidy] New checker to detect suspicious string constructor.Etienne Bergeron2016-04-212-0/+37
| | | | | | | | | | | | | | | | | | | Summary: Checker to validate string constructor parameters. A common mistake is to swap parameter for the fill-constructor. ``` std::string str('x', 4); std::string str('4', x); ``` Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19146 llvm-svn: 267011
* [clang-tidy] Add new checker for comparison with runtime string functions.Etienne Bergeron2016-04-212-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This checker is validating suspicious usage of string compare functions. Example: ``` if (strcmp(...)) // Implicitly compare to zero if (!strcmp(...)) // Won't warn if (strcmp(...) != 0) // Won't warn ``` This patch was checked over large amount of code. There is three checks: [*] Implicit comparator to zero (coding-style, many warnings found), [*] Suspicious implicit cast to non-integral (bugs!?, almost none found), [*] Comparison to suspicious constant (bugs!?, found two cases), Example: [[https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c | https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c]] ``` else if(strcmp(id, "select") == 0) { array->array[i].key1 = 25; } else if(strcmp(id, "sk") == 28) // BUG!? { array->array[i].key1 = 20; } ``` Reviewers: alexfh Subscribers: Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D18703 llvm-svn: 267009
* Initial version of misc-unused-using-decl check.Daniel Jasper2016-04-192-0/+15
| | | | llvm-svn: 266735
* [clang-tidy] Add new checker for suspicious sizeof expressionsEtienne Bergeron2016-04-152-0/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check is finding suspicious cases of sizeof expression. Sizeof expression is returning the size (in bytes) of a type or an expression. Programmers often abuse or misuse this expression. This checker is adding common set of patterns to detect some of these bad constructs. Some examples found by this checker: R/packages/ifultools/ifultools/src/fra_neig.c ``` /* free buffer memory */ (void) mutil_free( dist_buff, sizeof( ctr * sizeof( double ) ) ); (void) mutil_free( nidx_buff, sizeof( ctr * sizeof( sint32 ) ) ); ``` graphviz/v2_20_2/lib/common/utils.c ``` static Dtdisc_t mapDisc = { offsetof(item, p), sizeof(2 * sizeof(void *)), offsetof(item, link), (Dtmake_f) newItem, (Dtfree_f) freeItem, (Dtcompar_f) cmpItem, NIL(Dthash_f), NIL(Dtmemory_f), NIL(Dtevent_f) }; ``` mDNSResponder/mDNSShared/dnsextd.c ``` context = ( TCPContext* ) malloc( sizeof( TCPContext ) ); require_action( context, exit, err = mStatus_NoMemoryErr; LogErr( "AcceptTCPConnection", "malloc" ) ); mDNSPlatformMemZero( context, sizeof( sizeof( TCPContext ) ) ); context->d = self; ``` Reviewers: alexfh Subscribers: malcolm.parsons, Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D19014 llvm-svn: 266451
* [clang-tidy] Add checker for operations between integrals and pointersEtienne Bergeron2016-04-152-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check is finding suspicious operations involving pointers and integral types; which are most likely bugs. Examples: subversion/v1_6/subversion/libsvn_subr/utf.c ``` static const char * fuzzy_escape(const char *src, apr_size_t len, apr_pool_t *pool) { [...] while (src_orig < src_end) { if (! svn_ctype_isascii(*src_orig) || src_orig == '\0') // Should be *src_orig { ``` apache2/v2_2_23/modules/metadata/mod_headers.c ``` static char *parse_format_tag(apr_pool_t *p, format_tag *tag, const char **sa) { [...] tag->arg = '\0'; // ERROR: tag->arg has type char* /* grab the argument if there is one */ if (*s == '{') { ++s; tag->arg = ap_getword(p,&s,'}'); } ``` Reviewers: alexfh Subscribers: Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D19118 llvm-svn: 266450
* [clang-tidy] Add check misc-multiple-statement-macroSamuel Benzaquen2016-04-142-0/+17
| | | | | | | | | | | | | | | Summary: The check detects multi-statement macros that are used in unbraced conditionals. Only the first statement will be part of the conditionals and the rest will fall outside of it and executed unconditionally. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18766 llvm-svn: 266369
* [clang-tidy] Fix documentation generation.Etienne Bergeron2016-04-141-0/+1
| | | | | | | | | | | | Summary: The patch is fixing the generation of clang-tidy documentation. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19121 llvm-svn: 266333
* Complete support for C++ Core Guidelines Type.6: Always initialize a member ↵Alexander Kornienko2016-04-131-9/+28
| | | | | | | | | | | | | | | | variable. Summary: Added the remaining features needed to satisfy C++ Core Guideline Type.6: Always initialize a member variable to cppcoreguidelines-pro-type-member-init. The check now flags all default-constructed uses of record types without user-provided default constructors that would leave their memory in an undefined state. The check suggests value initializing them instead. Reviewers: flx, alexfh, aaron.ballman Subscribers: klimek, aaron.ballman, LegalizeAdulthood, cfe-commits Patch by Michael Miller! Differential Revision: http://reviews.llvm.org/D18584 llvm-svn: 266191
* [clang-tidy] Add a readability-deleted-default clang-tidy check.Alexander Kornienko2016-04-132-0/+22
| | | | | | | | | | | Checks if constructors and assignment operators that are marked '= default' are actually deleted by the compiler. Patch by Alex Pilkiewicz! Differential Revision: http://reviews.llvm.org/D18961 llvm-svn: 266190
* [clang-tidy] cppcoreguidelines-interfaces-global-initAlexander Kornienko2016-04-082-0/+15
| | | | | | | | | | | | | | | | Summary: This check flags initializers of globals that access extern objects, and therefore can lead to order-of-initialization problems (this recommandation is part of CPP core guidelines). Note that this only checks half of the guideline for now (it does not enforce using constexpr functions). Reviewers: aaron.ballman, alexfh Subscribers: aaron.ballman, etienneb, Eugene.Zelenko, cfe-commits Patch by Clement Courbet! Differential Revision: http://reviews.llvm.org/D18649 llvm-svn: 265774
* [clang-tidy] add new checker for string literal with NUL character.Etienne Bergeron2016-04-072-0/+39
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds the support for detecting suspicious string literals and their //incorrect// usage. The following example shows a incorrect character escaping leading to an embedded NUL character. ``` std::string str = "\0x42"; // Should be "\x42". ``` The patch also add detection of truncated literal when a literal is passed to a string constructor. Reviewers: hokein, alexfh Subscribers: LegalizeAdulthood, bcraig, Eugene.Zelenko, bkramer, cfe-commits Differential Revision: http://reviews.llvm.org/D18783 llvm-svn: 265691
* [clang-tidy] fix building clang-tidy documentation.Etienne Bergeron2016-04-062-2/+3
| | | | | | | | | | | | | | | | | | Summary: The clang-tidy documentation can't be generated because of broken links. ``` Warning, treated as error: /home/etienneb/llvm/llvm/tools/clang/tools/extra/docs/clang-tidy/checks/google-readability-function-size.rst:: WARNING: document isn't included in any toctree ``` Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18803 llvm-svn: 265539
* [clang-tidy] Extension of checker misc-misplaced-widening-castGabor Horvath2016-04-061-4/+15
| | | | | | | | | | | | | | | | | | Summary: Existing checker misc-misplaced-widening-cast was extended: - New use cases: casted expression as lhs or rhs of a logical comparison or function argument - New types: beside int, long and long long various char types, short and int128 added - New option to check implicit casts: forgetting a cast is at least as common and as dangerous as misplacing it. This option can be disabled. This patch depends on AST Matcher patches D17986 and D18243 and also contains fix for checker misc-bool-pointer-implicit-conversion needed because of the fix in the AST Matcher patch. Reviewers: hokein, alexfh Subscribers: o.gyorgy, xazax.hun, cfe-commits Differential Revision: http://reviews.llvm.org/D17987 llvm-svn: 265532
* [clang-tidy] Add a check to detect static definitions in anonymous namespace.Haojian Wu2016-04-052-0/+18
| | | | | | | | | | | | Summary: Fixes PR26595 Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18180 llvm-svn: 265384
* [clang-tidy] Fix documentation of misc-suspicious-missing-commaEtienne Bergeron2016-04-051-3/+12
| | | | | | | | | | | | | | | Summary: The clang-tidy documentation generation was broken since commit : http://reviews.llvm.org/D18457 I ran locally the documentation generation and I fixed errors related to that specific check. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18764 llvm-svn: 265375
* [Clang-tidy] Improve checks documentation consistency.Eugene Zelenko2016-04-0234-124/+85
| | | | | | Differential revision: http://reviews.llvm.org/D18717 llvm-svn: 265205
* Update release notes with list of checks added since 3.8.Eugene Zelenko2016-03-314-11/+13
| | | | | | | | Fix some checks documentation style. Differential revision: http://reviews.llvm.org/D18582 llvm-svn: 265072
* [clang-tidy] Add a new checker to detect missing comma in initializer list.Etienne Bergeron2016-03-312-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This checker is able to detect missing comma in an array of string literals. ``` const char* A[] = { "abc", "def" // missing comma (no compiler warnings) "ghi", }; ``` The ratio of false-positive is reduced by restricting the size of the array considered and the ratio of missing comma. To validate the quantity of false positive, the checker was tried over LLVM and chromium code and detected these cases: [[ http://reviews.llvm.org/D18454 | http://reviews.llvm.org/D18454 ]] [[https://codereview.chromium.org/1807753002/ | https://codereview.chromium.org/1807753002/]] [[https://codereview.chromium.org/1826193002/ | https://codereview.chromium.org/1826193002/]] [[https://codereview.chromium.org/1805713002/ | https://codereview.chromium.org/1805713002/]] Reviewers: alexfh Subscribers: LegalizeAdulthood, szdominik, xazax.hun, cfe-commits Differential Revision: http://reviews.llvm.org/D18457 llvm-svn: 265033
* [clang-tidy] readability check for const params in declarationsAlexander Kornienko2016-03-302-1/+19
| | | | | | | | | | | | | | Summary: Adds a clang-tidy warning for top-level consts in function declarations. Reviewers: hokein, sbenza, alexfh Subscribers: cfe-commits Patch by Matt Kulukundis! Differential Revision: http://reviews.llvm.org/D18408 llvm-svn: 264856
* [clang-tidy] Add check to detect dangling references in value handlers.Samuel Benzaquen2016-03-292-0/+35
| | | | | | | | | | | | | | | | | | | | | | Summary: Add check misc-dangling-handle to detect dangling references in value handlers like std::experimental::string_view. It provides a configuration option to specify other handle types that should also be checked. Right now it detects: - Construction from temporaries. - Assignment from temporaries. - Return statements from temporaries or locals. - Insertion into containers from temporaries. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17811 llvm-svn: 264759
* [clang-tidy] Add performance check to flag function parameters of expensive ↵Felix Berger2016-03-292-0/+34
| | | | | | | | | | | | to copy types that can be safely converted to const references. Reviewers: alexfh Subscribers: fowles, cfe-commits Differential Revision: http://reviews.llvm.org/D17491 llvm-svn: 264694
* clang-tidy: Add check modernize-raw-string-literalRichard Thomson2016-03-272-0/+47
| | | | llvm-svn: 264539
* Add clang-tools-extra release notesRichard Thomson2016-03-271-0/+1
| | | | llvm-svn: 264531
* Add check for unneeded copies of localsHaojian Wu2016-03-231-6/+9
| | | | | | | | | | | | | | Summary: Extends the UnnecessaryCopyInitialization to detect copies of local variables and parameters that are unneeded. Patch by Matt Kulukundis! Reviewers: alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18149 llvm-svn: 264146
* [clang-tidy] Extend UnnecessaryCopyInitialization check to trigger on ↵Felix Berger2016-03-051-0/+34
| | | | | | | | | | | | | | | | non-const copies that can be safely converted to const references. Summary: Move code shared between UnnecessaryCopyInitialization and ForRangeCopyCheck into utilities files. Add more test cases for UnnecessaryCopyInitialization and disable fixes inside of macros. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17488 llvm-svn: 262781
* fix some minor typos in the docSylvestre Ledru2016-03-032-4/+4
| | | | llvm-svn: 262655
* Fix two minor syntax issues in the documentationSylvestre Ledru2016-03-032-1/+2
| | | | llvm-svn: 262654
* [clang-tidy] Do not emit warnings from misc-suspicious-semicolon when the ↵Gabor Horvath2016-03-031-6/+6
| | | | | | compilation fails. llvm-svn: 262615
* [clang-tidy] Documentation fixes.Gabor Horvath2016-03-031-6/+6
| | | | llvm-svn: 262601
* [clang-tidy] Minor change in the docAlexander Kornienko2016-02-261-1/+1
| | | | llvm-svn: 261998
* Remove a blank line at EOF. NFCAlexander Kornienko2016-02-251-1/+0
| | | | llvm-svn: 261940
* Add a new check, readability-redundant-string-init, that checks unnecessary ↵Alexander Kornienko2016-02-252-0/+17
| | | | | | | | | | | | | | string initializations. Reviewers: hokein, alexfh Subscribers: cfe-commits Patch by Shuai Wang! Differential Revision: http://reviews.llvm.org/D17586 llvm-svn: 261939
* [clang-tidy] update links to Google Code Style in docsHaojian Wu2016-02-258-8/+8
| | | | | | | | | | | | | | Summary: Because of the recent Google Code shutdown links to the Google Code Style up there are no longer relevant. Reviewers: alexfh, hokein Subscribers: cfe-commits Patch by Kirill Bobyrev! Differential Revision: http://reviews.llvm.org/D17602 llvm-svn: 261868
* [clang-tidy] introduce modernize-deprecated-headers checkAlexander Kornienko2016-02-242-0/+46
| | | | | | | | | | | | | | | | | Summary: This patch introduces the modernize-deprecated-headers check, which is supposed to replace deprecated C library headers with the C++ STL-ones. For information see documentation; for exmaples see the test cases. Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh Subscribers: cfe-commits Patch by Kirill Bobyrev! Differential Revision: http://reviews.llvm.org/D17484 llvm-svn: 261738
* [clang-tidy] Added a check for forward declaration in the potentially wrong ↵Alexander Kornienko2016-02-242-0/+20
| | | | | | | | | | | | | | | | | namespace Adds a new check "misc-forward-declaration-namespace". In check, A forward declaration is considerred in a potentially wrong namespace if there is any definition/declaration with the same name exists in a different namespace. Reviewers: akuegel, hokein, alexfh Patch by Eric Liu! Differential Revision: http://reviews.llvm.org/D17195 llvm-svn: 261737
* [clang-tidy] Updated docs on testing clang-tidy checks.Alexander Kornienko2016-02-231-2/+20
| | | | llvm-svn: 261622
* Add a new check, cert-env33-c, that diagnoses uses of system(), popen(), and ↵Aaron Ballman2016-02-222-0/+14
| | | | | | _popen() to execute a command processor. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=2130132 llvm-svn: 261530
* [clang-tidy] Describe modules, link to LLVM development docs, other minor ↵Alexander Kornienko2016-02-201-11/+46
| | | | | | updates llvm-svn: 261431
* Add a new check, cert-flp30-c, that diagnoses loop induction expressions of ↵Aaron Ballman2016-02-192-0/+12
| | | | | | floating-point type. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters llvm-svn: 261324
* fix an indent issue in the doc which causes sphinx to fail with some versionsSylvestre Ledru2016-02-151-1/+1
| | | | llvm-svn: 260912
OpenPOWER on IntegriCloud