summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] readability-avoid-const-params-in-decls template instantiation ↵Malcolm Parsons2016-10-111-1/+6
| | | | | | | | | | | | | | bugfix Summary: Bugfix for 30398. Don't warn for template instantiations Reviewers: aaron.ballman, hokein, alexfh Subscribers: omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D24652 llvm-svn: 283873
* Revert "Revert "Add a static_assert to enforce that parameters to ↵Mehdi Amini2016-10-071-2/+2
| | | | | | | | | llvm::format() are not totally unsafe"" This reverts commit r283510 and reapply r283509, with updates to clang-tools-extra as well. llvm-svn: 283525
* [clang-tidy] Use isStaticStorageClass ast matcher.Haojian Wu2016-09-271-12/+6
| | | | llvm-svn: 282476
* [clang-tidy] make readability-redundant-smartptr-get report get() usage in ↵Kirill Bobyrev2016-09-261-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | conditions This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases: ``` std::unique_ptr<void> ptr; if (ptr.get()) if (ptr.get() == NULL) if (ptr.get() != NULL) ``` This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko. However, there still are cases not detected by the check. They can be found in `void Negative()` function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24893 llvm-svn: 282386
* Revert r282382; it had no reference to Revision.Kirill Bobyrev2016-09-261-18/+11
| | | | llvm-svn: 282384
* [clang-tidy] make readability-redundant-smartptr-get report get() usage in ↵Kirill Bobyrev2016-09-261-11/+18
| | | | | | | | | | | | | | | | | | | | | | | conditions This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases: ``` std::unique_ptr<void> ptr; if (ptr.get()) if (ptr.get() == NULL) if (ptr.get() != NULL) ``` This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko. However, there still are cases not detected by the check. They can be found in `void Negative()` function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp. llvm-svn: 282382
* [clang-tidy] Cleaning up language options.Gabor Horvath2016-09-248-23/+20
| | | | | | Differential Revision: https://reviews.llvm.org/D24881 llvm-svn: 282319
* [clang-tidy] Bugfix for readability-redundant-control-flow checkKirill Bobyrev2016-09-161-1/+1
| | | | | | | | | | | | | This check did not create FixItHints when the statement before the redundant control flow was not followed by a semicolon. Patch by Malcolm Parsons! Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D24500 llvm-svn: 281713
* [clang-tidy] Fix naming in container-size-empty.Kirill Bobyrev2016-09-131-4/+4
| | | | llvm-svn: 281313
* [clang-tidy] Extend readability-container-size-empty to arbitrary class with ↵Kirill Bobyrev2016-09-131-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | size() and empty() This patch extends readability-container-size-empty check allowing it to produce warnings not only for STL containers, but also for containers, which provide two functions matching following signatures: * `size_type size() const;` * `bool empty() const;` Where `size_type` can be any kind of integer type. This functionality was proposed in https://llvm.org/bugs/show_bug.cgi?id=26823 by Eugene Zelenko. Approval: alexfh Reviewers: alexfh, aaron.ballman, Eugene.Zelenko Subscribers: etienneb, Prazek, hokein, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D24349 llvm-svn: 281307
* [clang-tidy] readability-misplaced-array-index: add new check that warns ↵Daniel Marjamaki2016-09-124-0/+97
| | | | | | | | | | when array index is misplaced. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D21134 llvm-svn: 281206
* [clang-tidy] readability-non-const-parameter: add new check that warns when ↵Daniel Marjamaki2016-08-234-0/+282
| | | | | | | | | | | | | | function parameters should be const The check will warn when the constness will make the function interface safer. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D15332 llvm-svn: 279507
* [clang-tidy] readability-implicit-bool-cast forgets to store its options.Haojian Wu2016-08-162-6/+19
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23544 llvm-svn: 278791
* [clang-tidy] enhance readability-else-after-returnKirill Bobyrev2016-08-101-7/+16
| | | | | | | | | | | | `readability-else-after-return` only warns about `return` calls, but LLVM Coding Standars stat that `throw`, `continue`, `goto`, etc after `return` calls are bad, too. Reviwers: alexfh, aaron.ballman Differential Revision: https://reviews.llvm.org/D23265 llvm-svn: 278257
* Sorting includes; NFC.Aaron Ballman2016-07-291-1/+1
| | | | llvm-svn: 277217
* [clang-tidy] readability-identifier-naming - support for other case typesKirill Bobyrev2016-07-202-0/+31
| | | | | | | | | | | | | | | | | | | Added Camel_Snake_Case and camel_Snake_Back class Camel_Snake_Case_Class_Name { void private_Camel_Snake_Back_Method_Name(); } Patch by James Reynolds! Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21472 llvm-svn: 276110
* clang-tidy/readability-identifier-naming: crash on ↵Matthias Gehre2016-07-091-3/+4
| | | | | | | | | | | | | | | | DependentTemplateSpecializationType Summary: Previously, the added test cases crashed because the passed a null Decl to addUsage(). Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22188 llvm-svn: 274985
* [clang-tidy] Do not match on lambdas.Samuel Benzaquen2016-06-281-4/+8
| | | | | | | | We match on the generated FunctionDecl of the lambda and try to fix it. This causes a crash. The right behavior is to ignore lambdas, because they are a definition. llvm-svn: 274019
* Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.Tim Shen2016-06-211-9/+9
| | | | | | | | | | | | Summary: This is a fix for the new ExprWithCleanups introduced by clang's temporary variable lifetime marks change. Reviewers: bkramer, sbenza, angelgarcia, alexth Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D21243 llvm-svn: 273310
* [clang-tidy] Fix doxygen errors. NFC.Alexander Kornienko2016-06-171-2/+2
| | | | llvm-svn: 272994
* [clang-tidy] readability-identifier-naming - Support for MacrosAlexander Kornienko2016-06-172-22/+187
| | | | | | | | | | | | | | | | | | | | | Summary: Added support for macro definitions. -- 1. Added a pre-processor callback to catch macro definitions 2. Changed the type of the failure map so that macros and declarations can share the same map 3. Added extra tests to ensure fix-ups work using the new map 4. Added fix-ups for type aliases in variable and function declarations as part of adding the new tests Reviewers: alexfh Subscribers: Eugene.Zelenko, cfe-commits Patch by James Reynolds! Differential Revision: http://reviews.llvm.org/D21020 llvm-svn: 272993
* Apply performance-unnecessary-value-param to clang-tidy.Benjamin Kramer2016-06-152-2/+2
| | | | | | With minor manual tweaks. No functionality change intended. llvm-svn: 272795
* [clang-tidy] readability-identifier-naming - Support for Type AliasesAlexander Kornienko2016-06-071-0/+4
| | | | | | | | | | | | | | Summary: Added support for Type Alias declarations. Reviewers: alexfh Subscribers: cfe-commits Patch by James Reynolds! Differential Revision: http://reviews.llvm.org/D20856 llvm-svn: 271992
* [clang-tidy] Do not try to suggest a fix if the parameter is partially in a ↵Samuel Benzaquen2016-06-061-0/+6
| | | | | | | | | macro. It is not easy to tell where to do the suggestion and whether the suggestion will be correct. llvm-svn: 271896
* Fix uninitialized memory access when the token 'const' is not present inSamuel Benzaquen2016-06-011-5/+8
| | | | | | | | | the program. If the token is not there, we still warn but we don't try to give a fixit hint. llvm-svn: 271426
* [ASTMatchers] Added ignoringParenImpCasts to has matchersPiotr Padlewski2016-05-312-6/+7
| | | | | | | | | has matcher changed behaviour, and now it matches "as is" and doesn't skip implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271289
* Speed up check by using a recursive visitor.Samuel Benzaquen2016-05-252-66/+84
| | | | | | | | | | | | | | | | Summary: Use a recursive visitor instead of forEachDescendant() matcher. The latter requires several layers of virtual function calls for each node and it is more expensive than the visitor. Benchmark results show improvement of ~6% walltime in clang-tidy. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20597 llvm-svn: 270714
* [clang-tidy] Lift common matchers to utils namespaceEtienne Bergeron2016-05-172-16/+3
| | | | | | | | | | | | | | Summary: This patch is lifting matchers used by more than one checkers to the common namespace. Reviewers: aaron.ballman, alexfh Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D19841 llvm-svn: 269804
* [clang-tidy] Refactoring of FixHintUtilsEtienne Bergeron2016-05-111-6/+4
| | | | | | | | | | | | | | Summary: Refactor some checkers to use the tooling re-writing API. see: http://reviews.llvm.org/D19941 Reviewers: klimek, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19807 llvm-svn: 269210
* [clang-tidy] Cleaning namespaces to be more consistant across checkers.Etienne Bergeron2016-05-026-7/+14
| | | | | | | | | | | | | | Summary: The goal of the patch is to bring checkers in their appropriate namespace. This path doesn't change any behavior. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19811 llvm-svn: 268264
* clangTidyReadabilityModule: Add clangTidyUtils in libdeps, corresponding to ↵NAKAMURA Takumi2016-04-221-0/+1
| | | | | | r267003. llvm-svn: 267087
* [clang-tidy] Cleanup some ast-matchers and lift some to utils.Etienne Bergeron2016-04-212-44/+12
| | | | | | | | | | | | | | | | Summary: Little cleanup to lift-out and to remove some frequently used ast-matchers. Some of theses matchers are candidates to be lifted to ASTMatchers.h. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19200 llvm-svn: 267003
* [clang-tidy] readability-container-size-empty fixesGabor Horvath2016-04-191-8/+12
| | | | | | | | | | | | Summary: This patch fixes PR27410 and adds std::basic_string support. Reviewers: Eugene.Zelenko, hokein Subscribers: cfe-commits, o.gyorgy Differential Revision: http://reviews.llvm.org/D19262 llvm-svn: 266734
* [clang-tidy] Add more detection rules for redundant c_str calls.Etienne Bergeron2016-04-151-2/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The string class contains methods which support receiving either a string literal or a string object. For example, calls to append can receive either a char* or a string. ``` string& append (const string& str); string& append (const char* s); ``` Which make these cases equivalent, and the .c_str() useless: ``` std::string s = "123"; str.append(s); str.append(s.c_str()); ``` In these cases, removing .c_str() doesn't provide any size or speed improvement. It's only a readability issue. If the string contains embedded NUL characters, the string literal and the string object won't produce the same semantic. Reviewers: alexfh, sbenza Subscribers: LegalizeAdulthood, aaron.ballman, chapuni, Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D18475 llvm-svn: 266463
* [clang-tidy] Add a readability-deleted-default clang-tidy check.Alexander Kornienko2016-04-134-0/+109
| | | | | | | | | | | 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] fix readability-avoid-const-params-in-decls creating invalid ↵Matthias Gehre2016-04-121-7/+40
| | | | | | | | | | | | | | | | | | | | code in fix-its Summary: The Fix-Its for the added test cases were before: -void F11(const unsigned int /*version*/); +void F11(unsigned int int /*version*/); -void F12(const bool b = true); +void F12(_Bool true); Reviewers: fowles, hokein, sbenza, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18993 llvm-svn: 266044
* [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a ↵Benjamin Kramer2016-04-071-2/+2
| | | | | | | | | | DiagnosticBuilder Going through a string removes some of the smarts of the diagnosic printer and makes the code more complicated. This change has some cosmetic impact on the output but that's mostly minor. llvm-svn: 265680
* [clang-tidy] Fix FP with readability-redundant-string-init for default argumentsEtienne Bergeron2016-04-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Clang-tidy is reporting a warning of redundant string initialisation on a string parameter initialized with empty string. See bug: 27087 The reported example is: ``` #include <string> void fn(std::string a = ""); ``` Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18829 llvm-svn: 265671
* [clang-tidy] Add a check to detect static definitions in anonymous namespace.Haojian Wu2016-04-054-0/+111
| | | | | | | | | | | | Summary: Fixes PR26595 Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18180 llvm-svn: 265384
* [clang-tidy] Fix MSVC build.Alexander Kornienko2016-03-301-1/+2
| | | | llvm-svn: 264862
* [clang-tidy] readability check for const params in declarationsAlexander Kornienko2016-03-304-0/+108
| | | | | | | | | | | | | | 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 support for different char-types for the ↵Etienne Bergeron2016-03-241-14/+14
| | | | | | | | | | | | | | | | | | | | | readability-redundant-string-cstr checker. Summary: The current checker is able to recognize std::string but does not recognize other string variants. This patch is adding the support for any string defined with basic_string without considering the the underlying char type. The most common variant is: 'std::wstring' based on 'wchar_t'. There are also other string variants added to the standard: u16string, u32string, etc... Reviewers: alexfh Subscribers: mamai, dblaikie, cfe-commits Differential Revision: http://reviews.llvm.org/D18412 llvm-svn: 264325
* [clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.Etienne Bergeron2016-03-221-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The string constructors are not defined using optional parameters and are not recognize by the checker. The constructor defined in the MSVC header is defined with 1 parameter. Therefore, patterns are not recognized by the checker. The current patch add support to accept constructor with only one parameter. Repro on a Visual Studio 14 installation with the following code: ``` void f1(const std::string &s) { f1(s.c_str()); } ``` In the xstring.h header, the constructors are defined this way: ``` basic_string(const _Myt& _Right) [...] basic_string(const _Myt& _Right, const _Alloc& _Al) [...] ``` The CXXConstructExpr to recognize only contains 1 parameter. ``` CXXConstructExpr 0x3f1a070 <C:\src\llvm\examples\test.cc:6:6, col:14> 'const std::string':'const class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >' 'void (const char *) __attribute__((thiscall))' `-CXXMemberCallExpr 0x3f1a008 <col:6, col:14> 'const char *' `-MemberExpr 0x3f19fe0 <col:6, col:8> '<bound member function type>' .c_str 0x3cc22f8 `-DeclRefExpr 0x3f19fc8 <col:6> 'const std::string':'const class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >' lvalue ParmVar 0x3f19c80 's' 'const std::string &' ``` Reviewers: aaron.ballman, alexfh Subscribers: aemerson Differential Revision: http://reviews.llvm.org/D18285 llvm-svn: 264075
* [clang-tidy] Fix redundant-string-init check with msvc 14 headers.Etienne Bergeron2016-03-221-15/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The string constructors are not defined using optional parameters and are not recognized by the redundant-string-init checker. The following patch fixes the redundant-string-init checker for the Visual Studio 14 headers file. The matcher now accept both variant (with 1 and 2 parameters). Also added new unittests. Similar issue than: [[ http://reviews.llvm.org/D18285 | review ]] In the xstring.h header, the constructors are defined this way: ``` basic_string(const _Myt& _Right) [...] basic_string(const _Myt& _Right, const _Alloc& _Al) [...] ``` Reviewers: alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18293 llvm-svn: 264069
* IdentifierNamingCheck.cpp: try to fix MSVC buildHans Wennborg2016-02-291-4/+4
| | | | | | | | | It was failing to build with: clang-tidy\readability\IdentifierNamingCheck.cpp(640): error C2882: 'format' : illegal use of namespace identifier in expression llvm-svn: 262257
* Add a new check, readability-redundant-string-init, that checks unnecessary ↵Alexander Kornienko2016-02-254-0/+98
| | | | | | | | | | | | | | 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-252-2/+2
| | | | | | | | | | | | | | 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] Match the type against the get() method we are calling,Samuel Benzaquen2016-02-171-5/+5
| | | | | | | | | instead of a get() method we find in the class. The duck typed smart pointer class could have overloaded get() methods and we should only skip the one that matches. llvm-svn: 261102
* [clang-tidy] Fix an assert failure of ForStmt in ↵Haojian Wu2016-02-161-2/+2
| | | | | | | | | | | | `readability-braces-around-statements` check. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17134 llvm-svn: 260952
* Reapply r260096.Aaron Ballman2016-02-122-162/+140
| | | | | | | | | | | | Expand the simplify boolean expression check to handle implicit conversion of integral types to bool and improve the handling of implicit conversion of member pointers to bool. Implicit conversion of member pointers are replaced with explicit comparisons to nullptr. Implicit conversions of integral types are replaced with explicit comparisons to 0. Patch by Richard Thomson. llvm-svn: 260681
OpenPOWER on IntegriCloud