summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/utils
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-085-13/+9
| | | | | | | | | | | | | | | | 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] Ignore incomplete types when determining whether they are ↵Felix Berger2016-11-041-1/+1
| | | | | | | | | | | | | | | | expensive to copy Summary: IsExpensiveToCopy can return false positives for incomplete types, so ignore them. All existing ClangTidy tests that depend on this function still pass as the types are complete. Reviewers: alexfh, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26195 llvm-svn: 286008
* Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-177-0/+345
| | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: beanz, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 284368
* Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"Haojian Wu2016-10-126-342/+0
| | | | | | This reverts commit r283981. This patch breaks the buildbot. llvm-svn: 283985
* [ClangTidy] Add UsingInserter and NamespaceAliaserHaojian Wu2016-10-126-0/+342
| | | | | | | | | | | | | | | | Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring) Patch by Julian Bangert! Reviewers: alexfh, hokein Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D24997 llvm-svn: 283981
* Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle ↵Aaron Ballman2016-10-041-0/+5
| | | | | | | | | | classes with default constructors that are defaulted or are not present in the AST. Classes with virtual methods or virtual bases are not trivially default constructible, so their members and bases need to be initialized. Patch by Malcolm Parsons. llvm-svn: 283224
* [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init ↵Matthias Gehre2016-09-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with in-class initializers Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where ``` warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init] ``` is emitted on ``` struct MyStruct { int a = 5; int b = 7; }; int main() { MyStruct s; } ``` Reviewers: alexfh, aaron.ballman Subscribers: nemanjai, cfe-commits Differential Revision: https://reviews.llvm.org/D24848 llvm-svn: 282625
* [clang-tidy] Some tweaks on header guard checks.Haojian Wu2016-08-262-18/+14
| | | | | | | | * Implement missing storeOption interfaces. * Remove unnecessary parameter copy in isHeaderFileExtension. * Fix doc style. llvm-svn: 279814
* [clang-tidy] Added hh, hxx and hpp to header guard checks.Mads Ravn2016-08-264-5/+34
| | | | | | | | Changed the extension check to include the option of ",h,hh,hpp,hxx" instead of just returning whether the file ended with ".h". Differential revision: https://reviews.llvm.org/D20512 llvm-svn: 279803
* [clang-tidy] Fixes to modernize-use-emplacePiotr Padlewski2016-07-291-2/+0
| | | | | | | | Not everything is valid, but it should works for 99.8% cases https://reviews.llvm.org/D22208 llvm-svn: 277097
* [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const ↵Felix Berger2016-07-015-14/+84
| | | | | | | | | | | | | | | | | | | | value parameter can be moved. Summary: Make check more useful in the following two cases: The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor. The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator. In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended. Reviewers: alexfh, sbenza Subscribers: cfe-commits, Prazek Differential Revision: http://reviews.llvm.org/D20277 llvm-svn: 274380
* Remove ignoringImplicit from clang-tidy.Cong Liu2016-06-241-5/+0
| | | | llvm-svn: 273660
* [clang-tidy] Add modernize-use-emplacePiotr Padlewski2016-06-211-0/+2
| | | | | | | | | | Summary: Add check that replaces call of push_back to emplace_back Reviewers: hokein Differential Revision: http://reviews.llvm.org/D20964 llvm-svn: 273275
* [clang-tidy] More doc fixes. NFC.Alexander Kornienko2016-06-173-30/+30
| | | | llvm-svn: 272995
* [clang-tidy] Fix doxygen errors. NFC.Alexander Kornienko2016-06-176-47/+55
| | | | llvm-svn: 272994
* [clang-tidy] Fix a functional change from r269656.Benjamin Kramer2016-05-181-3/+4
| | | | | | | | Instead of forming char ranges that patch made us form token ranges, which behave subtly different. Sadly I'm only seeing this as part of a larger test case that I haven't fully reduced yet. llvm-svn: 269896
* [clang-tidy] Lift common matchers to utils namespaceEtienne Bergeron2016-05-171-0/+5
| | | | | | | | | | | | | | 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] Cleanups utils filesEtienne Bergeron2016-05-169-46/+19
| | | | | | | | | | | | | | | | | | | Summary: Cleanup some code by using appropriate APIs. Some coding style cleanups. There is no behavior changes. - Function `IncludeSorter::CreateFixIt` can be replaced by `FixItHint::CreateReplacement`. - Function `cleanPath` is a wrapper for `llvm::sys::path::remove_dots`. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20279 llvm-svn: 269656
* [clang-tidy] TypeTraits - Type is not expensive to copy when it has a ↵Felix Berger2016-05-142-3/+20
| | | | | | | | | | | | deleted copy constructor. Reviewers: alexfh, sbenza Subscribers: etienneb, aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D20170 llvm-svn: 269581
* [clang-tidy] Lift parsing of sequence of names functions to utils.Etienne Bergeron2016-05-103-1/+72
| | | | | | | | | | | | | | | | Summary: Lift some common code used by multiple checkers. This function is also used by checkers that are coming. It is quite common for a checker to parse a list of names. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19846 llvm-svn: 269065
* [clang-tidy] Cleanup namespace in utils folder.Etienne Bergeron2016-05-0315-17/+41
| | | | | | | | | | | | | | Summary: This is a step forward cleaning up the namespaces in clang-tidy/utils. There is no behavior change. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19819 llvm-svn: 268356
* [clang-tidy] Cleanup some ast-matchers and lift some to utils.Etienne Bergeron2016-04-211-0/+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
* Complete support for C++ Core Guidelines Type.6: Always initialize a member ↵Alexander Kornienko2016-04-133-0/+87
| | | | | | | | | | | | | | | | 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] Extend UnnecessaryCopyInitialization check to trigger on ↵Felix Berger2016-03-055-0/+200
| | | | | | | | | | | | | | | | 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
* [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when ↵Haojian Wu2016-03-021-2/+3
| | | | | | | | | | | | | | IncludeInserter handles macro header file. Summary: Also Fixes PR24749. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17805 llvm-svn: 262484
* [clang-tdiy] Add header file extension configuration support.Haojian Wu2016-02-053-0/+117
| | | | | | | | | | | | Summary: * Add a `HeaderFileExtensions` check option in misc-definitions-in-headers, google-build-namespaces and google-global-names-in-headers. Reviewers: aaron.ballman, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16113 llvm-svn: 259879
* Remove autoconf supportChris Bieneman2016-01-261-12/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "Now I am become Death, the destroyer of worlds." -J. Robert Oppenheimer Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D16475 llvm-svn: 258864
* [clang-tidy] Add UnnecessaryCopyInitialization check to new "performance" ↵Alexander Kornienko2015-12-303-0/+69
| | | | | | | | | | | | | | | | | | | module in ClangTidy Summary: The patch adds a new ClangTidy check that detects when expensive-to-copy types are unnecessarily copy initialized from a const reference that has the same or are larger scope than the copy. It currently only detects this when the copied variable is const qualified. But this will be extended to non const variables if they are only used in a const fashion. Reviewers: alexfh Subscribers: cfe-commits Patch by Felix Berger! Differential Revision: http://reviews.llvm.org/D15623 llvm-svn: 256632
* [clang-tidy] Sort includes case-sensitively.Alexander Kornienko2015-12-101-4/+1
| | | | | | | | | The motivation is: 1. consistency with clang-format, vim :sort etc. 2. we don't want the tools to depend on the current locale to do the include sorting llvm-svn: 255243
* Replace the custom AST matcher for nothrow functions with the canonical AST ↵Aaron Ballman2015-12-021-16/+0
| | | | | | matcher from r254516. llvm-svn: 254517
* Add a new checker, cert-err58-cpp, that checks for static or thread_local ↵Aaron Ballman2015-12-011-0/+16
| | | | | | | | objects that use a throwing constructor. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions llvm-svn: 254415
* Make isExpensiveToCopy() tri-state.Manuel Klimek2015-10-233-4/+8
| | | | | | This allows returning "don't know" for dependent types. llvm-svn: 251103
* Revert "Apply modernize-use-default to clang-tools-extra."David Blaikie2015-10-201-1/+1
| | | | | | | | | Breaks the build in GCC 4.7.2 (see http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3 for example) This reverts commit r250824. llvm-svn: 250862
* Apply modernize-use-default to clang-tools-extra.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13889 llvm-svn: 250824
* Improved the misc-move-constructor-init check to identify arguments that are ↵Aaron Ballman2015-10-066-0/+105
| | | | | | | | passed by value but copy assigned to class data members when the non-deleted move constructor is a better fit. Patch by Felix Berger! llvm-svn: 249429
* SourceRanges are small and trivially copyable, don't them by reference. NFCCraig Topper2015-10-041-2/+2
| | | | llvm-svn: 249258
* [clang-tidy] Update docs for clang-tidy checks. NFCAlexander Kornienko2015-08-271-1/+1
| | | | | | | | | | | Changes mostly address formatting and unification of the style. Use MarkDown style for inline code snippets and lists. Added some text for a few checks. The idea is to move most of the documentation out to separate rST files and have implementation files refer to the corresponding documentation files. llvm-svn: 246169
* Fix IncludeInserter to allow for more than one added header per file.Daniel Jasper2015-08-191-3/+2
| | | | | | | | Also adapt tests a bit to make it possible to test this. Removed checking the number of errors reported per test. It was never actually checked and doesn't seem particularly relevant to the test itself. llvm-svn: 245500
* [clang-tidy] Move IncludeSorter.* and IncludeInserter.* to clang-tidy/utils/Alexander Kornienko2015-08-145-0/+532
| | | | | | | This is better structurally and it also fixes a linker error in the configure build. llvm-svn: 245052
* [clang-tidy] Don't duplicate the leading slash.Alexander Kornienko2015-07-271-1/+1
| | | | llvm-svn: 243265
* Update to match clang r236404.Richard Smith2015-05-041-4/+4
| | | | llvm-svn: 236405
* [clang-tidy] Fixed header guards using clang-tidy llvm-header-guard check. NFC.Alexander Kornienko2015-03-091-3/+3
| | | | | | | | | | The patch was generated using this command: $ clang-tidy/tool/run-clang-tidy.py -header-filter=.*clang-tidy.* -fix \ -checks=-*,llvm-header-guard clang-tidy.* $ svn revert --recursive clangt-tidy/llvm/ (to revert a few buggy fixes) llvm-svn: 231669
* [clang-tidy] Use the new ArrayRef<FixItHint> inserter.Alexander Kornienko2015-02-251-8/+5
| | | | llvm-svn: 230497
* Fix llvm-header-guard check.Alexander Kornienko2014-10-152-7/+18
| | | | | | | | | | | | | | | | | Summary: This patch makes the check work better for LLVM code: * always fix existing #endif comments * use one space before the comment (+allow customization for other styles) Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5795 llvm-svn: 219789
* Make a variable local so it's lifetime becomes more obvious.Benjamin Kramer2014-09-171-6/+7
| | | | | | NFC llvm-svn: 217952
* [clang-tidy] Don't emit the same fixit multiple times.Benjamin Kramer2014-09-171-5/+5
| | | | | | | | | | If we had many header files we would attach the fix-it for all files to all warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter in some edge cases. Sadly I failed to create a small test case for this. While there move fix-its instead of copying. llvm-svn: 217951
* [clang-tidy] When emitting header guard fixes bundle all fix-its into oneBenjamin Kramer2014-09-161-17/+31
| | | | | | | | | warning. Before we would emit two warnings if the header guard was wrong and the comment on a trailing #endif also needed fixing. llvm-svn: 217890
* Implemented clang-tidy-check-specific options.Alexander Kornienko2014-09-121-0/+2
| | | | | | | | | | | | | | | | | Summary: Each check can implement readOptions and storeOptions methods to read and store custom options. Each check's options are stored in a local namespace to avoid name collisions and provide some sort of context to the user. Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5296 llvm-svn: 217661
* [clang-tidy] Don't try to fix header guard #endif comments if there are escapedBenjamin Kramer2014-09-101-0/+7
| | | | | | | | newlines involved. Getting that right is just not worth it. llvm-svn: 217480
* Unique_ptrify PPCallbacks ownership. Goes with clang r217474.Craig Topper2014-09-101-1/+2
| | | | llvm-svn: 217475
OpenPOWER on IntegriCloud