summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Minor cleanups in readability-container-size-empty checkerAlexander Kornienko2015-01-221-13/+6
| | | | | | | | | | | * Removed an unused header * Simplified the custom ast_matchers http://reviews.llvm.org/D7088 Patch by Gábor Horváth! llvm-svn: 226810
* [clang-tidy] Make ClangTidyOptionsProvider::getOptions return by value.Alexander Kornienko2015-01-202-4/+4
| | | | | | | Returning by reference limits possible implementations and doesn't bring any benefits as all callers make copies of the returned value anyway. llvm-svn: 226553
* clang-tidy: 'size' call that could be replaced with 'empty' on STL containersAlexander Kornienko2015-01-154-0/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We are porting some of the checkers at a company we developed to the Clang Tidy infrastructure. We would like to open source the checkers that may be useful for the community as well. This patch is the first checker that is being ported to Clang Tidy. We also added fix-it hints, and applied them to LLVM: http://reviews.llvm.org/D6924 The code compiled and the unit tests are passed after the fixits was applied. The documentation of the checker: /// The emptiness of a container should be checked using the empty method /// instead of the size method. It is not guaranteed that size is a /// constant-time function, and it is generally more efficient and also shows /// clearer intent to use empty. Furthermore some containers may implement the /// empty method but not implement the size method. Using empty whenever /// possible makes it easier to switch to another container in the future. It also uses some custom ASTMatchers. In case you find them useful I can submit them as separate patches to clang. I will apply your suggestions to this patch. http://reviews.llvm.org/D6925 Patch by Gábor Horváth! llvm-svn: 226172
* clang-tidy: Add initial check for "Don't use else after return".Daniel Jasper2015-01-144-0/+80
| | | | | | | | | | | As per the LLVM coding standards: http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return Initial version, probably still quite a bit to do until this is really useful. Review: http://reviews.llvm.org/D6927 llvm-svn: 226025
* [cleanup] Re-sort the #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-1412-16/+16
| | | | | | | 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: [misc-use-override] Fix 'override' insertion.Daniel Jasper2015-01-091-9/+23
| | | | | | | | | | Before: void f() __attribute__((override unused)) After: void f() override __attribute__((unused)) llvm-svn: 225519
* Fixed a typo in a comment. NFC.Alexander Kornienko2014-12-191-1/+1
| | | | llvm-svn: 224581
* [clang-tidy] Fix a typo.Alexander Kornienko2014-12-091-2/+3
| | | | llvm-svn: 223777
* [clang-tidy] Extended the example check, added a fix-it, etc.Alexander Kornienko2014-12-091-12/+23
| | | | llvm-svn: 223771
* clang-tidy: Add a basic python script to generate checks.Daniel Jasper2014-12-091-0/+214
| | | | | | | | There are still a vast range of improvements that can be done to this, but it seems like an ok initial version. Suggestions or patches are highly welcome. llvm-svn: 223766
* [clang-tidy] google-runtime-int: Don't check C code.Alexander Kornienko2014-12-081-0/+4
| | | | llvm-svn: 223651
* [clang-tidy] Add clang-tidy check for unique_ptr's reset+release -> moveAlexander Kornienko2014-12-054-0/+108
| | | | | | | | | | | Replace x.reset(y.release()); with x = std::move(y); If y is rvalue, replace with x = y; instead. http://reviews.llvm.org/D6485 Patch by Alexey Sokolov! llvm-svn: 223460
* [clang-tidy] Update help messages and docs.Alexander Kornienko2014-12-031-6/+21
| | | | | | Fixed incorrect examples of configuration, clarified the usage of -dump-config. llvm-svn: 223235
* [clang-tidy] google-explicit-constructor: don't match in template instantiationsAlexander Kornienko2014-11-301-1/+2
| | | | | | | This helps avoiding false positives related to the recently added std::initializer_list<> handling. llvm-svn: 222981
* [clang-tidy] Support initializer_list in google-explicit-constructor checkAlexander Kornienko2014-11-271-6/+34
| | | | | | | | | | | | | | | | | | | Summary: According to the Google C++ Style Guide, constructors taking a single std::initializer_list<> should not be marked explicit. This change also changes the messages according to conventions used in Clang diagnostics: no capitalization of the first letter, no trailing dot. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D6427 llvm-svn: 222878
* clang-tidy: Add override before the first attribute.Daniel Jasper2014-11-251-2/+4
| | | | | | Apparently attributes aren't sorted by source location. llvm-svn: 222751
* [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] Count errors in ClangTidyDiagnosticConsumerAlexander Kornienko2014-11-201-0/+3
| | | | | | | This re-applies r222363 reverted in r222390 after compilation errors in our out-of-tree clang-tidy tests were fixed. llvm-svn: 222427
* Revert r222363: "[clang-tidy] Count errors in ClangTidyDiagnosticConsumer"Hans Wennborg2014-11-191-3/+0
| | | | | | | This was causing clang-tidy invocations that would previously pass despite source errors to fail. llvm-svn: 222390
* [clang-tidy] Count errors in ClangTidyDiagnosticConsumerAlexander Kornienko2014-11-191-0/+3
| | | | llvm-svn: 222363
* Remove uses of StringMap::GetOrCreateValue in favor of stl-compatible API usageDavid Blaikie2014-11-191-2/+2
| | | | llvm-svn: 222305
* [clang-tidy] Move the missing namespace comment warnings to the closing braceAlexander Kornienko2014-11-171-1/+9
| | | | | | | | | | | | | | | | | | | Summary: The google-readability-namespace-comments/llvm-namespace-comment warnings are quite confusing when they appear at the beginning of a long namespace and the closing brace is not in sight. For convenience added notes pointing to the start of the namespace. Reviewers: klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D6251 llvm-svn: 222145
* [clang-tidy] google-readability-function: skip std::nullptr_tAlexander Kornienko2014-11-051-0/+4
| | | | | | | Parameters of type std::nullptr_t can only have one value, so it doesn't make sense to name them. llvm-svn: 221340
* [clang-tidy] Don't print a message if there's no error.Alexander Kornienko2014-11-041-2/+3
| | | | llvm-svn: 221272
* [clang-tidy] Added -fix-errors optionAlexander Kornienko2014-11-031-4/+26
| | | | | | | | | | | | | | | | | | Summary: Added -fix-errors option to allow applying fixes when compiler errors are present. Without this flag -fix would bail out if there are compiler errors. This is needed to avoid applying wrong fixes if Clang fails to recover from compilation errors correctly. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D6059 llvm-svn: 221152
* [CMake] Add dependencies on clangToolingCore.NAKAMURA Takumi2014-10-301-0/+1
| | | | llvm-svn: 220890
* Fix Makefiles after r220867.Daniel Jasper2014-10-291-3/+3
| | | | llvm-svn: 220868
* Shrink the set of checks enabled by default.Alexander Kornienko2014-10-291-5/+4
| | | | | | | | | | | | | | | | Summary: Enable only compiler diagnostics and safe static analyzer checks by default. Let the defaults be conservative and safe for an average project. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6027 llvm-svn: 220865
* [clang-tidy] Added -system-headers option.Alexander Kornienko2014-10-284-1/+15
| | | | | | | Added -system-headers option to allow display of warnings from system headers. This is needed for testing libcxx, for example. llvm-svn: 220826
* [clang-tidy] Bring order to check registration.Alexander Kornienko2014-10-269-18/+62
| | | | | | | | | | | | | | | | 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
* Add flag --enable-check-profile to clang-tidy.Samuel Benzaquen2014-10-235-5/+89
| | | | | | | | | | | | | | | Summary: Add flag --enable-check-profile to clang-tidy. It turns on per-matcher profiles in MatchFinder and prints a report to stderr at the end. Reviewers: alexfh Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5937 llvm-svn: 220491
* [clang-tidy] Add support for custom configuration file names/formats.Alexander Kornienko2014-10-202-40/+111
| | | | | | | | | | | | | | Summary: We're using different clang-tidy frontends (command-line, batch analysis jobs, code review integration), some of which are limited in the choice of configuration format. In order to avoid duplication of configuration information, we need to support the same configuration format in the command-line tool. This patch adds an extension point to make this possible without rewriting FileOptionsProvider. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5821 llvm-svn: 220199
* [clang-tidy] Minor fixes for the NamespaceCommentCheck.Alexander Kornienko2014-10-161-4/+6
| | | | | | | | * Make SmallVector size enough for all groups. * Allow trailing period in the comment. * Fix "// anonymous namespace qqq". llvm-svn: 219926
* [clang-tidy] Default options in modules.Alexander Kornienko2014-10-166-11/+39
| | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* [clang-tidy] Move some of the misc checks to readability/Alexander Kornienko2014-10-159-18/+35
| | | | | | | | | | | | | | | | | | | Summary: Some of the misc checks belong to readability/. I'm moving them there without changing check names for now. As the next step, I want to register some of these checks in the google and llvm modules with suitable settings (e.g. BracesAroundStatementsCheck). I'm not sure if we want to create a "readability" module, probably not. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5792 llvm-svn: 219786
* [clang-tidy] misc-braces-around-statements.ShortStatementLines optionAlexander Kornienko2014-10-132-7/+45
| | | | | | | | | | | | | | | | Add option ShortStatementLines to trigger this check only if the statement spans over at least a given number of lines. Modifications from the original patch: merged test/clang-tidy/misc-braces-around-statements-always.cpp into test/clang-tidy/misc-braces-around-statements.cpp and removed unnecessary CHECK-NOTs from the tests. http://reviews.llvm.org/D5642 Patch by Marek Kurdej! llvm-svn: 219611
* [clang-tidy] Allow space between "TODO" and "(user)"Alexander Kornienko2014-10-051-1/+1
| | | | llvm-svn: 219091
* [clang-tidy] Add check misc-braces-around-statements.Alexander Kornienko2014-10-024-0/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | This check looks for if statements and loops: for, range-for, while and do-while, and verifies that the inside statements are inside braces '{}'. If not, proposes to add braces around them. Example: if (condition) action(); becomes if (condition) { action(); } This check ought to be used with the -format option, so that the braces be well-formatted. Patch by Marek Kurdej! http://reviews.llvm.org/D5395 llvm-svn: 218898
* [clang-tidy] Clarify a comment.Alexander Kornienko2014-10-011-1/+2
| | | | | | No functional changes. llvm-svn: 218772
* [clang-tidy] Handle c-style casts from/to enums.Alexander Kornienko2014-10-011-2/+13
| | | | | | | | | | | | | | Summary: Convert c-style casts between integral end enum types to static_cast<>. Reviewers: klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5558 llvm-svn: 218760
* Fix a typoAlexander Kornienko2014-09-261-1/+1
| | | | llvm-svn: 218512
* [clang-tidy] Add a -config={YAML} option.Alexander Kornienko2014-09-261-6/+35
| | | | | | | | | | | | | | | | Summary: Add -config option to allow specifying configuration in YAML/JSON format on the command line. Reviewers: klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5501 llvm-svn: 218511
* Clang-tidy google-readability-function check: don't warn on gmockAlexander Kornienko2014-09-251-0/+5
| | | | | | | | | | | | | | testing::Unused parameters. Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5479 llvm-svn: 218443
* Provide user name in ClangTidyOptions.Alexander Kornienko2014-09-245-33/+49
| | | | | | | | | | | | | | | | | | | Summary: This adds the ClangTidyOptions::User field and fills it from the USER or the USERNAME environment variable, if possible. The FileOptionsProvider now takes "default" options instead of "fallback" options, as it now uses these when an option is not set in the configuration file (one exception is the checks list). Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5440 llvm-svn: 218402
* Drop superfluous semicolon. GCC's -pedantic warns about this.Benjamin Kramer2014-09-231-1/+1
| | | | llvm-svn: 218310
* Try to pacify dash-using linux distros with a very old-school shell variable ↵Benjamin Kramer2014-09-221-0/+1
| | | | | | | | compare. While there fix the cmake shared build. llvm-svn: 218274
* Add missing dependency.Alexander Kornienko2014-09-221-2/+2
| | | | llvm-svn: 218249
* Add NamespaceCommentCheck to the Google module.Alexander Kornienko2014-09-229-18/+50
| | | | | | | | | | | | | | | | | 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
* run-clang-tidy.py: don't fail when running without -checks=.Alexander Kornienko2014-09-221-2/+5
| | | | llvm-svn: 218227
OpenPOWER on IntegriCloud