summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with ↵Zinovy Nis2018-05-012-20/+32
| | | | | | | | | | 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-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+8
| | | | | | | | | | | | | | | | | | | | | 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
* Fix up after clang r331155.Richard Smith2018-04-304-10/+11
| | | | llvm-svn: 331156
* [clang-tidy] Improve bugprone-unused-return-value checkJonathan Coe2018-04-241-10/+28
| | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D46003 llvm-svn: 330719
* update test to use ivar in implementation instead of class extensionYan Zhang2018-04-231-0/+4
| | | | | | | | | | | | | | 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-4/+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] add new check to find out objc ivars which do not have prefix '_'Yan Zhang2018-04-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Fix unused-variable warning.Haojian Wu2018-04-191-1/+2
| | | | llvm-svn: 330327
* add extra acronyms for objc property namesYan Zhang2018-04-181-0/+5
| | | | | | | | | | | | | | 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-183-14/+26
| | | | | | | | | | | | | | 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] Fix ParentVirtualCallCheck for old MSVS compilersZinovy Nis2018-04-131-1/+2
| | | | llvm-svn: 329999
* [clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFCZinovy Nis2018-04-131-16/+11
| | | | llvm-svn: 329994
* Revert "[clang-tidy] [modernize-use-auto] Get only a length of token, not ↵Zinovy Nis2018-04-121-3/+2
| | | | | | | | | the token itself" This reverts r329873 as getting only a single token length is wrong for multi-token type names, like 'unsigned long int'. llvm-svn: 329949
* [clang-tidy] readability-function-size: add VariableThreshold param.Roman Lebedev2018-04-122-2/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Get only a length of token, not the token ↵Zinovy Nis2018-04-121-2/+3
| | | | | | itself llvm-svn: 329873
* [clang-tidy] add missing assignment operations in hicpp-signed-bitwiseJonas Toth2018-04-111-9/+9
| | | | | | | | | | | | | 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-104-0/+124
| | | | | | | | | 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][modernize]: don't forget to actually link to Tooling.Roman Lebedev2018-04-101-0/+1
| | | | | | | | | | | | | | | | Fixes build for me: [1/5] Linking CXX shared library lib/libclangTidyModernizeModule.so.7svn FAILED: lib/libclangTidyModernizeModule.so.7svn <...> /usr/local/bin/ld.lld: error: undefined symbol: clang::tooling::fixit::internal::getText(clang::SourceRange, clang::ASTContext const&) >>> referenced by UseAutoCheck.cpp >>> tools/clang/tools/extra/clang-tidy/modernize/CMakeFiles/clangTidyModernizeModule.dir/UseAutoCheck.cpp.o:(clang::tidy::modernize::UseAutoCheck::replaceExpr(clang::DeclStmt const*, clang::ASTContext*, llvm::function_ref<clang::QualType (clang::Expr const*)>, llvm::StringRef)) Refs. D45405, rL329730. llvm-svn: 329750
* [clang-tidy][Fuchsia]: don't forget to actually link to Google Module.Roman Lebedev2018-04-101-0/+1
| | | | | | | | | | | | | | | Fixes build for me: [1/7] Linking CXX shared library lib/libclangTidyFuchsiaModule.so.7svn FAILED: lib/libclangTidyFuchsiaModule.so.7svn <...> /usr/local/bin/ld.lld: error: undefined symbol: clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck(llvm::StringRef, clang::tidy::ClangTidyContext*) >>> referenced by FuchsiaTidyModule.cpp >>> tools/clang/tools/extra/clang-tidy/fuchsia/CMakeFiles/clangTidyFuchsiaModule.dir/FuchsiaTidyModule.cpp.o:(std::_Function_handler<clang::tidy::ClangTidyCheck* (llvm::StringRef, clang::tidy::ClangTidyContext*), void clang::tidy::ClangTidyCheckFactories::registerCheck<clang::tidy::google::build::UnnamedNamespaceInHeaderCheck>(llvm::StringRef)::'lambda'(llvm::StringRef, clang::tidy::ClangTidyContext*)>::_M_invoke(std::_Any_data const&, llvm::StringRef&&, clang::tidy::ClangTidyContext*&&)) Refs. D45447, rCTE329720 llvm-svn: 329749
* [clang-tidy] [modernize-use-auto] Fix members initialization orderZinovy Nis2018-04-101-2/+3
| | | | llvm-svn: 329740
* [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name ↵Zinovy Nis2018-04-102-2/+11
| | | | | | | | | | | | 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] Adding alias for anon namespaces in header (fuchsia module)Julie Hockett2018-04-101-0/+3
| | | | | | | | | Adding alias to google-build-namespaces to the Fuchsia module (checks for anonymous namespaces in headers). Differential Revision: https://reviews.llvm.org/D45447 llvm-svn: 329720
* [clang-tidy] Return non-zero exit code for clang errors.Alexander Kornienko2018-04-091-4/+16
| | | | | | | | | | | | | | | | 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
* Fix unused variable warning.Chandler Carruth2018-04-091-0/+1
| | | | llvm-svn: 329550
* [clang-tidy] Fix compilation for MSVS@PSP4 for ParentVirtualCallCheck.cppZinovy Nis2018-04-071-8/+7
| | | | | | | | There's an error for PSP4 platform only: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\algorithm(95): error C2719: '_Pred': formal parameter with requested alignment of 8 won't be aligned llvm-svn: 329495
* [clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: ↵Zinovy Nis2018-04-061-2/+5
| | | | | | find_if predicate llvm-svn: 329454
* [clang-tidy] Fix compilation for ParentVirtualCallCheck.cppZinovy Nis2018-04-061-7/+10
| | | | llvm-svn: 329452
* [clang-tidy] Check if grand-..parent's virtual method was called instead of ↵Zinovy Nis2018-04-064-0/+193
| | | | | | | | | | | | | 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] Sort includes; NFCGeorge Burgess IV2018-04-061-1/+1
| | | | llvm-svn: 329428
* [clang-tidy] Remove google-runtime-member-string-referencesBenjamin Kramer2018-04-054-109/+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] Check for sizeof that call functionsHaojian Wu2018-04-032-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | 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-11/+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/+11
| | | | | | | | | | | | 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] Enable Python 3 support for add_new_check.pyJonathan Coe2018-03-241-16/+18
| | | | | | | | | | | | | | Summary: In Python 3, filters are lazily evaluated and strings are not bytes. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D44217 llvm-svn: 328418
* clang-tidy, modularize: return non-zero exit code on errorsAlexander Kornienko2018-03-221-2/+2
| | | | | | | 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] Use :doc: for check links in Release Notes.Eugene Zelenko2018-03-212-4/+4
| | | | | | Differential revision: https://reviews.llvm.org/D44694 llvm-svn: 328115
* [Fix] fix type deduction on ARM and MSVCJonas Toth2018-03-211-1/+1
| | | | llvm-svn: 328108
* [clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking testJonas Toth2018-03-214-0/+236
| | | | | | | | | | | | | | | | | | | | | | | | 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-3/+22
| | | | | | | | | | | | | | | | | | | | 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
* run-clang-tidy: forward clang-tidy exit statusMiklos Vajna2018-03-191-4/+10
| | | | | | | | | | | | | | | | | | | | | Exit with a non-zero value in case any of the underlying clang-tidy invocations exit with a non-zero value. This is useful in case WarningsAsErrors is enabled for some of the checks: if any of those checks find something, the exit status now reflects that. Also add the ability to use run-clang-tidy.py via lit, and assert that the exit code is not 0 when modernize-use-auto is triggered intentionally. Reviewers: alexfh, aaron.ballman Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D44366 llvm-svn: 327854
* [clang-tidy] New check bugprone-unused-return-valueAlexander Kornienko2018-03-194-0/+125
| | | | | | | | | | | | | | | | | | | | | Summary: Detects function calls where the return value is unused. Checked functions can be configured. Reviewers: alexfh, aaron.ballman, ilya-biryukov, hokein Reviewed By: alexfh, aaron.ballman Subscribers: hintonda, JonasToth, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Patch by Kalle Huttunen! Differential Revision: https://reviews.llvm.org/D41655 llvm-svn: 327833
* [clang-tidy] rename_check.py misc-unused-raii bugprone-unused-raii ↵Alexander Kornienko2018-03-156-18/+19
| | | | | | --check_class_name=UnusedRAIICheck llvm-svn: 327610
* Fixed filename in a comment. NFCAlexander Kornienko2018-03-151-1/+1
| | | | llvm-svn: 327609
* [clang-tidy] rename_check.py misc-sizeof-container bugprone-sizeof-containerAlexander Kornienko2018-03-156-11/+12
| | | | llvm-svn: 327608
* [clang-tidy] rename_check.py misc-sizeof-expression bugprone-sizeof-expressionAlexander Kornienko2018-03-156-12/+12
| | | | llvm-svn: 327607
* [clang-tidy] rename_check.py {misc,bugprone}-macro-parenthesesAlexander Kornienko2018-03-156-11/+11
| | | | llvm-svn: 327606
* [clang-tidy] Add Zircon module to clang-tidyJulie Hockett2018-03-147-0/+163
| | | | | | | | | | Adding a Zircon module to clang-tidy for checks specific to the Zircon kernel, and adding a checker to fuchsia-zx (for zircon) to flag instances where specific objects are temporarily created. Differential Revision: https://reviews.llvm.org/D44346 llvm-svn: 327590
* [clang-tidy] Fixing incorrect commentJulie Hockett2018-03-131-1/+1
| | | | llvm-svn: 327452
OpenPOWER on IntegriCloud