summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is ↵Zinovy Nis2018-05-221-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | of ExprWithCleanups type bool foo(A &S) { if (S != (A)S) return false; return true; } is fixed into (w/o this patch) ... return !S != (A)S; // negotiation affects first operand only } instead of (with this patch) ... return S == (A)S; // note == instead of != } Differential Revision: https://reviews.llvm.org/D47122 llvm-svn: 333003
* [clang-tidy] Add a flag to enable alpha checkersAlexander Kornienko2018-05-171-0/+6
| | | | | | | | | | | | | | | | Summary: The alpha checkers can already be enabled using the clang driver, this allows them to be enabled using the clang-tidy as well. This can make it easier to test the alpha checkers with projects which already support the compile_commands.json. It will also allow more people to give feedback and patches about the alpha checkers since they can run it as part of clang tidy checks. Reviewers: aaron.ballman, hokein, ilya-biryukov, alexfh, lebedev.ri, xbolva00 Reviewed By: aaron.ballman, alexfh, lebedev.ri, xbolva00 Subscribers: xbolva00, NoQ, dcoughlin, lebedev.ri, xazax.hun, cfe-commits Patch by Paul Fultz II! Differential Revision: https://reviews.llvm.org/D46159 llvm-svn: 332609
* Add a new check, readability-simplify-subscript-expr, that diagnoses array ↵Aaron Ballman2018-05-161-0/+108
| | | | | | | | | | subscript expressions that can be simplified. Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly. Patch by Shuai Wang. llvm-svn: 332519
* [clang-tidy/google-readability-casting] Disable check for Objective-C++Ben Hamilton2018-05-161-0/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, `google-readability-casting` was disabled for Objective-C. The Google Objective-C++ style allows both Objective-C and C++ style in the same file. Since clang-tidy doesn't have a good way to allow multiple styles per file, this disables the check for Objective-C++. Test Plan: New tests added. Ran tests with: % make -j16 check-clang-tools Before diff, confirmed tests failed: https://reviews.llvm.org/P8081 After diff, confirrmed tests passed. Reviewers: alexfh, Wizard, hokein, stephanemoore Reviewed By: alexfh, Wizard, stephanemoore Subscribers: stephanemoore, cfe-commits, bkramer, klimek Differential Revision: https://reviews.llvm.org/D46659 llvm-svn: 332516
* [clang-tidy] Add terminating continue checkGabor Horvath2018-05-141-0/+65
| | | | | | | | Patch by: Daniel Kolozsvari! Differential Revision: https://reviews.llvm.org/D33844 llvm-svn: 332223
* [clang-tidy] Fixing fuchsia-restrict-includes-headers testJulie Hockett2018-05-111-3/+3
| | | | | | Removing filepaths so windows tests pass. llvm-svn: 332152
* [clang-tidy] Cleaning up test output (fuchsia-restrict-system-includes)Julie Hockett2018-05-111-8/+9
| | | | | | | This should fix the break in the fuchsia-restrict-system-includes-headers test. llvm-svn: 332143
* Reland "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-1113-0/+72
| | | | | | This relands r332125 with a fixed test. llvm-svn: 332141
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-1113-70/+0
| | | | | | This reverts commit r332125 for a failing test. llvm-svn: 332131
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-1113-0/+70
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 332125
* Revert "[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module"Julie Hockett2018-05-099-51/+0
| | | | | | This reverts commit r331930, which was landed by accident. llvm-svn: 331934
* [clang-tidy] Adding RestrictSystemIncludes check to Fuchsia moduleJulie Hockett2018-05-099-0/+51
| | | | | | | | | | Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 331930
* Do not warn on unused parameters for functions with empty bodies.Manuel Klimek2018-05-092-48/+51
| | | | | | If a function has an empty body, all parameters are trivially unused. llvm-svn: 331875
* [clang-tidy] Profile is a per-AST (per-TU) data.Roman Lebedev2018-05-082-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in D45931, currently, profiling output of clang-tidy is somewhat not great. It outputs one profile at the end of the execution, and that profile contains the data from the last TU that was processed. So if the tool run on multiple TU's, the data is not accumulated, it is simply discarded. It would be nice to improve this. This differential is the first step - make this profiling info per-TU, and output it after the tool has finished processing each TU. In particular, when `ClangTidyASTConsumer` destructor runs. Next step will be to add a CSV (JSON?) printer to store said profiles under user-specified directory prefix. Reviewers: alexfh, sbenza Reviewed By: alexfh Subscribers: Eugene.Zelenko, mgorny, xazax.hun, mgrang, klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46504 llvm-svn: 331763
* Add support for ObjC property name to be a single acronym.Yan Zhang2018-05-042-0/+2
| | | | | | | | | | | | | | | | | | | | | Summary: This change will support cases like: ``` @property(assign, nonatomic) int ID; ``` Reviewers: benhamilton, hokein Reviewed By: benhamilton Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D46374 llvm-svn: 331545
* Simplify test clang-tidy-__clang_analyzer__macro.cpp Zinovy Nis2018-05-031-5/+0
| | | | llvm-svn: 331475
* [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for ↵Zinovy Nis2018-05-031-0/+10
| | | | | | | | | | | | | compatibility with clang static analyzer This macro is widely used in many well-known projects, ex. Chromium. But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered as [[no-return]], and a lot of false-positive warnings about nullptr dereferenced are emitted. Differential Revision: https://reviews.llvm.org/D46325 llvm-svn: 331474
* [clang-tidy] Remove AnalyzeTemporaryDtors option.Alexander Kornienko2018-05-031-2/+3
| | | | | | | | Remove the `AnalyzeTemporaryDtors` option, since the corresponding `cfg-temporary-dtors` option of the Static Analyzer defaults to `true` since r326461. llvm-svn: 331456
* [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with ↵Zinovy Nis2018-05-011-0/+2
| | | | | | | | | | raw literals It's useless and not safe to replace UTF-8 encoded with escaped ASCII to raw UTF-8 chars: "\xE2\x98\x83" ---> <snowman> So don't do it. llvm-svn: 331297
* [clang-tidy/google-runtime-int] Allow passing non-bitwidth types to ↵Ben Hamilton2018-05-011-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | printf()-style APIs Summary: The `google-runtime-int` check currently fires on calls like: printf("%lu", (unsigned long)foo); However, the style guide says: > Where possible, avoid passing arguments of types specified by > bitwidth typedefs to printf-based APIs. http://google.github.io/styleguide/cppguide.html#64-bit_Portability This diff relaxes the check to not fire on parameters to functions with the `__format__` attribute. (I didn't specifically check for `__printf__` since there are a few variations.) Test Plan: New tests added. Ran tests with: % make -j16 check-clang-tools Reviewers: alexfh, bkramer Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46293 llvm-svn: 331268
* [clang-tidy] Add Apple prefix acronyms to objc-property-declarationBen Hamilton2018-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | Summary: This adds a few common Apple first-party API prefixes as acronyms to `objc-property-declaration`. Here's a list showing where these come from: http://nshipster.com/namespacing/ Test Plan: New tests added. Ran tests with: % make -j16 check-clang-tools Reviewers: Wizard, hokein Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D46206 llvm-svn: 331267
* [clang-tidy] Improve bugprone-unused-return-value checkJonathan Coe2018-04-242-3/+70
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add support for checking class template member functions. Also add the following functions to be checked by default: - std::unique_ptr::release - std::basic_string::empty - std::vector::empty Reviewers: alexfh, hokein, aaron.ballman, ilya-biryukov Reviewed By: aaron.ballman Subscribers: jbcoe, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D45891 Patch by khuttun (Kalle Huttunen) llvm-svn: 330772
* [clang-tidy] Fix PR35468Gabor Horvath2018-04-241-0/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D46003 llvm-svn: 330719
* Fix tests after changes to clang-format in r330573.Manuel Klimek2018-04-231-11/+11
| | | | | | | | | | We do now both: - stop reformatting a sequence after a closing brace in more cases, in order to not misindent after an incorrect closing brace - format the closing brace when formatting the line containing the opening brace llvm-svn: 330580
* update readability-identifier-naming-objc test to use interface ivar. ↵Yan Zhang2018-04-231-5/+2
| | | | | | | | | | | | Implementation ivars are not supported in 32-bits OS. Reviewers: alexfh, chandlerc Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45936 llvm-svn: 330562
* update test to use ivar in implementation instead of class extensionYan Zhang2018-04-231-0/+15
| | | | | | | | | | | | | | Summary: using ivar in class extension is not supported in 32-bit architecture of MacOS. Reviewers: alexfh, hokein Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45912 llvm-svn: 330559
* Revert r330492: [clang-tidy] add new check to find out objc ivars which do ↵Chandler Carruth2018-04-211-15/+0
| | | | | | | | | | not have prefix '_' This commit has been breaking most bots for a day now. There is a fix proposed in https://reviews.llvm.org/D45912 but when I applied that I just got different errors. Reverting to get our bots back to green. llvm-svn: 330528
* [clang-tidy] Customize FileCheck prefix in check_clang-tidy.pyZinovy Nis2018-04-212-8/+38
| | | | | | | | | | | | | | | | | | | The patch introduces a new command line option '-check-suffix' for check_clang_tidy.py to allow multiple %check_clang_tidy% in a single test file. Sample: // RUN: %check_clang_tidy -check-suffix=FLAG-1 %s misc-unused-using-decls %t -- -- <options-set-1> // RUN: %check_clang_tidy -check-suffix=FLAG-2 %s misc-unused-using-decls %t -- -- <options-set-2> ... +// CHECK-MESSAGES-FLAG-1: :[[@LINE-4]]:10: warning: using decl 'B' is unused [misc-unused-using-decls] +// CHECK-MESSAGES-FLAG-2: :[[@LINE-7]]:10: warning: using decl 'A' is unused [misc-unused-using-decls] +// CHECK-FIXES-FLAG-1-NOT: using a::A;$ +// CHECK-FIXES-FLAG-2-NOT: using a::B;$ Differential Revision: https://reviews.llvm.org/D45776 llvm-svn: 330511
* [clang-tidy] add new check to find out objc ivars which do not have prefix '_'Yan Zhang2018-04-201-0/+15
| | | | | | | | | | | | | | | | | | | | | | | Summary: For code of ivar declaration: int barWithoutPrefix; The fix will be: int _barWithoutPrefix; Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov Reviewed By: alexfh Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D45392 llvm-svn: 330492
* Fix test from r330245 on Windows.Douglas Yung2018-04-181-1/+1
| | | | llvm-svn: 330305
* add extra acronyms for objc property namesYan Zhang2018-04-181-0/+2
| | | | | | | | | | | | | | Summary: This is to support general acronyms in Objective-C like 2G/3G/4G/... and coordinates X, Y, Z and W. Reviewers: benhamilton Reviewed By: benhamilton Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45750 llvm-svn: 330286
* [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.Haojian Wu2018-04-181-0/+12
| | | | | | | | | | | | | | Summary: Fix https://bugs.llvm.org/show_bug.cgi?id=34900. Reviewers: alexfh Reviewed By: alexfh Subscribers: JonasToth, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45697 llvm-svn: 330245
* [clang-tidy] readability-function-size: add VariableThreshold param.Roman Lebedev2018-04-122-6/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain. Note that this continues perverse practice of disabling the new option by default. I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice. If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so. But that is a lot of variables too... I was able to find one coding style referencing variable count: - https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions > Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong. Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh Reviewed By: aaron.ballman Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D44602 llvm-svn: 329902
* [clang-tidy] [modernize-use-auto] Fix test ↵Zinovy Nis2018-04-121-1/+1
| | | | | | | | | | modernize-use-auto-new-remove-stars.cpp after improvement 'tooling::fixit::getText' considers a length of "int *" to be 5 instead of 3 in a new algorithm in https://reviews.llvm.org/rCTE329873. It was the root of the test failure. llvm-svn: 329881
* [clang-tidy] fix buildbots from hicpp-signed-bitwiseJonas Toth2018-04-111-5/+10
| | | | | | | The applied patch to diagnose assignment operators introduced breakage on some architectures. This patch tries to rectify that. llvm-svn: 329790
* [clang-tidy] add missing assignment operations in hicpp-signed-bitwiseJonas Toth2018-04-112-29/+54
| | | | | | | | | | | | | This patch resolves the bug https://bugs.llvm.org/show_bug.cgi?id=36963. - implement missing assignment operators for hicpp-signed-bitwise - mention fix in release notes Reviewers: aaron.ballman, hokein, alexfh Differential: https://reviews.llvm.org/D45414 llvm-svn: 329789
* [clang-tidy] Add a `android-comparison-in-temp-failure-retry` checkGeorge Burgess IV2018-04-101-0/+148
| | | | | | | | | This check attempts to catch buggy uses of the `TEMP_FAILURE_RETRY` macro, which is provided by both Bionic and glibc. Differential Revision: https://reviews.llvm.org/D45059 llvm-svn: 329759
* [clang-tidy] Unbreak run-clang-tidy.cpp test ↵Roman Lebedev2018-04-101-0/+3
| | | | | | | | (modernize-use-auto.MinTypeNameLength) Again, refs. D45405, rL329730. llvm-svn: 329756
* [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name ↵Zinovy Nis2018-04-104-4/+37
| | | | | | | | | | | | length to be replaced with 'auto' The threshold option is 'MinTypeNameLength' with default value '5'. With MinTypeNameLength == 5 'int'/'bool' and 'const int'/'const bool' will not be converted to 'auto', while 'unsigned' will be. Differential Revision: https://reviews.llvm.org/D45405 llvm-svn: 329730
* [clang-tidy] Return non-zero exit code for clang errors.Alexander Kornienko2018-04-099-18/+34
| | | | | | | | | | | | | | | | Summary: Updated tests broken by this change. Fixes https://bugs.llvm.org/show_bug.cgi?id=27628 Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45258 llvm-svn: 329579
* [clang-tidy] Check if grand-..parent's virtual method was called instead of ↵Zinovy Nis2018-04-061-0/+179
| | | | | | | | | | | | | overridden parent's. class A {...int virtual foo() {...}...}; class B: public A {...int foo() override {...}...}; class C: public B {...int foo() override {... A::foo()...}}; ^^^^^^^^ warning: qualified name A::foo refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call] Differential Revision: https://reviews.llvm.org/D44295 llvm-svn: 329448
* [clang-tidy] Remove google-runtime-member-string-referencesBenjamin Kramer2018-04-051-49/+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
* [clang-tidy] Rename -warnings-as-errors tests. NFC.Alexander Kornienko2018-04-043-0/+0
| | | | | | The tests will be more discoverable with proper names. llvm-svn: 329182
* [clang-tidy] Check for sizeof that call functionsHaojian Wu2018-04-031-1/+71
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A common mistake that I have found in our codebase is calling a function to get an integer or enum that represents the type such as: ``` int numBytes = numElements * sizeof(x.GetType()); ``` So this extends the `sizeof` check to check for these cases. There is also a `WarnOnSizeOfCall` option so it can be disabled. Patch by Paul Fultz II! Reviewers: hokein, alexfh, aaron.ballman, ilya-biryukov Reviewed By: alexfh Subscribers: lebedev.ri, xazax.hun, jkorous-apple, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D44231 llvm-svn: 329073
* Revert r328932 as it caused Windows and MacOS bot failures.Mike Edwards2018-04-021-8/+0
| | | | | | http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43991/ llvm-svn: 328997
* [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for ↵Zinovy Nis2018-04-011-0/+8
| | | | | | | | | | | | compatibility with clang static analyzer This macro is widely used in many well-known projects, ex. Chromium. But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered as [[no-return]], and a lot of false-positive warnings about nullptr dereferenced are emitted. This patch fixes the issue by explicitly added macro definition. Differential Revision: https://reviews.llvm.org/D44906 llvm-svn: 328932
* clang-tidy, modularize: return non-zero exit code on errorsAlexander Kornienko2018-03-221-1/+1
| | | | | | | When no inputs given, the tools should not only produce the help message, but also return a non-zero exit code. Fixed tests accordingly. llvm-svn: 328199
* [clang-tidy] Marking hicpp-no-assembler-msvc unsupported on WindowsJulie Hockett2018-03-211-0/+2
| | | | | | | | After changes to lit.site.cfg.in, the test is now running (and failing) on windows, so temporarily marking it unsupported. See PR36855 for more details. llvm-svn: 328127
* [clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking testJonas Toth2018-03-212-0/+525
| | | | | | | | | | | | | | | | | | | | | | | | The original check did break the green buildbot in the sanitizer build. It took a while to redroduce and understand the issue. There occured a stackoverflow while parsing the AST. The testcase with 256 case labels was the problem because each case label added another stackframe. It seemed that the issue occured only in 'RelWithDebInfo' builds and not in normal sanitizer builds. To simplify the matchers the recognition for the different kinds of switch statements has been moved into a seperate function and will not be done with ASTMatchers. This is an attempt to reduce recursion and stacksize as well. The new check removed this big testcase. Covering all possible values is still implemented for bitfields and works there. The same logic on integer types will lead to the issue. Running it over LLVM gives the following results: Differential: https://reviews.llvm.org/D40737 llvm-svn: 328107
* [clang-tidy][modernize-make-unique] Checks c++14 flag before using ↵Alexander Kornienko2018-03-214-2/+23
| | | | | | | | | | | | | | | | | | | | std::make_unique Summary: For a c++11 code, the clang-tidy rule "modernize-make-unique" should return immediately, as std::make_unique is not supported. Reviewers: hokein, aaron.ballman, ilya-biryukov, alexfh Reviewed By: hokein, aaron.ballman, alexfh Subscribers: Quuxplusone, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Frederic Tingaud! Differential Revision: https://reviews.llvm.org/D43766 llvm-svn: 328101
OpenPOWER on IntegriCloud