aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/hicpp
AgeCommit message (Collapse)Author
2018-12-12Add explicit dependency on clangSerialization after rC348911Fangrui Song
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@348916 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-25A bit of AST matcher cleanup, NFC.Alexander Kornienko
Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347520 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14[clang-tidy] Avoid C arrays checkRoman Lebedev
Summary: [[ https://bugs.llvm.org/show_bug.cgi?id=39224 | PR39224 ]] As discussed, we can't always do the transform automatically due to that array-to-pointer decay of C array. In order to detect whether we can do said transform, we'd need to be able to see all usages of said array, which is, i would say, rather impossible if e.g. it is in the header. Thus right now no fixit exists. Exceptions: `extern "C"` code. References: * [[ https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es27-use-stdarray-or-stack_array-for-arrays-on-the-stack | CPPCG ES.27: Use std::array or stack_array for arrays on the stack ]] * [[ https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon1-prefer-using-stl-array-or-vector-instead-of-a-c-array | CPPCG SL.con.1: Prefer using STL array or vector instead of a C array ]] * HICPP `4.1.1 Ensure that a function argument does not undergo an array-to-pointer conversion` * MISRA `5-2-12 An identifier with array type passed as a function argument shall not decay to a pointer` Reviewers: aaron.ballman, JonasToth, alexfh, hokein, xazax.hun Reviewed By: JonasToth Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D53771 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@346835 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-26[clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check ↵Roman Lebedev
(CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4) Summary: Detects when the integral literal or floating point (decimal or hexadecimal) literal has non-uppercase suffix, and suggests to make the suffix uppercase, with fix-it. All valid combinations of suffixes are supported. ``` auto x = 1; // OK, no suffix. auto x = 1u; // warning: integer literal suffix 'u' is not upper-case auto x = 1U; // OK, suffix is uppercase. ... ``` This is a re-commit, the original was reverted by me in rL345305 due to discovered bugs. (implicit code, template instantiation) Tests were added, and the bugs were fixed. I'm unable to find any further bugs, hopefully there aren't any.. References: * [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]] * MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix * MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52670 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345381 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25[clang-tidy] Revert my readability-uppercase-literal-suffix check.Roman Lebedev
There are some lurking issues with the handling of the SourceManager. Somehow sometimes we end up extracting completely wrong portions of the source buffer. Reverts r344772, r44760, r344758, r344755. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345305 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-18[clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT ↵Roman Lebedev
DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4) Summary: Detects when the integral literal or floating point (decimal or hexadecimal) literal has non-uppercase suffix, and suggests to make the suffix uppercase, with fix-it. All valid combinations of suffixes are supported. ``` auto x = 1; // OK, no suffix. auto x = 1u; // warning: integer literal suffix 'u' is not upper-case auto x = 1U; // OK, suffix is uppercase. ... ``` References: * [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]] * MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix * MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52670 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344755 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-20[Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy ↵Eugene Zelenko
in source code headers. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342601 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17[clang-tidy] fix PR37913, templated exception factory diagnosed correctlyJonas Toth
Summary: PR37913 documents wrong behaviour for a templated exception factory function. The check does misidentify dependent types as not derived from std::exception. The fix to this problem is to ignore dependent types, the analysis works correctly on the instantiated function. Reviewers: aaron.ballman, alexfh, hokein, ilya-biryukov Reviewed By: alexfh Subscribers: lebedev.ri, nemanjai, mgorny, kbarton, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D48714 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09Port getLocStart -> getBeginLocStephen Kelly
Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339400 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11[clang-tidy] add missing assignment operations in hicpp-signed-bitwiseJonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@329789 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-21[Fix] fix type deduction on ARM and MSVCJonas Toth
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@328108 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-21[clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking testJonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@328107 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-28[clang-tidy] Another batch of checks to rename from misc- to bugprone-.Alexander Kornienko
Summary: clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor --check_class_name UndelegatedConstructor Reviewers: hokein, sammccall, aaron.ballman Subscribers: klimek, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D43870 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@326386 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-18[tidy] Move private ast matchers into anonymous namespaces to avoid ODR ↵Benjamin Kramer
conflicts. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@325467 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-17[clang-tidy] implement check for gotoJonas Toth
The usage of `goto` is discourage in C++ since forever. This check implements a warning for every `goto`. Even though there are (rare) valid use cases for `goto`, better high level constructs should be used. `goto` is used sometimes in C programs to free resources at the end of functions in the case of errors. This pattern is better implemented with RAII in C++. Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: lebedev.ri, jbcoe, Eugene.Zelenko, klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D41815 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@322626 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-17[clang-tidy] fix minor formatting issueJonas Toth
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@322624 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28[clang-tidy] Move more checks from misc- to performance-Alexander Kornienko
Summary: rename_check.py misc-move-const-arg performance-move-const-arg rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor Reviewers: hokein, xazax.hun Reviewed By: xazax.hun Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40507 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319183 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-25[clang-tidy] Fix link error (http://llvm.org/PR35417).Alexander Kornienko
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@318972 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-24[clang-tidy] Move a few more checks from misc to bugprone.Alexander Kornienko
Summary: clang_tidy/rename_check.py misc-assert-side-effect bugprone-assert-side-effect clang_tidy/rename_check.py misc-bool-pointer-implicit-conversion bugprone-bool-pointer-implicit-conversion clang_tidy/rename_check.py misc-fold-init-type bugprone-fold-init-type clang_tidy/rename_check.py misc-forward-declaration-namespace bugprone-forward-declaration-namespace clang_tidy/rename_check.py misc-inaccurate-erase bugprone-inaccurate-erase clang_tidy/rename_check.py misc-move-forwarding-reference bugprone-move-forwarding-reference clang_tidy/rename_check.py misc-multiple-statement-macro bugprone-multiple-statement-macro clang_tidy/rename_check.py misc-use-after-move bugprone-use-after-move clang_tidy/rename_check.py misc-virtual-near-miss bugprone-virtual-near-miss Manually fixed a reference to UseAfterMoveCheck in the hicpp module. Manually fixed header guards. Reviewers: hokein Reviewed By: hokein Subscribers: nemanjai, mgorny, javed.absar, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D40426 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@318950 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-20[clang-tidy] revert hicpp-multiway-paths-coveredJonas Toth
The address sanitizer found a stackoverflow with this patch. There is no obvious fix. This patch will be reapplied when the problem is found. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@318670 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-18[clang-tidy] Add new hicpp-multiway-paths-covered check for missing branchesJonas Toth
Summary: This check searches for missing `else` branches in `if-else if`-chains and missing `default` labels in `switch` statements, that use integers as condition. It is very similar to -Wswitch, but concentrates on integers only, since enums are already covered. The option to warn for missing `else` branches is deactivated by default, since it is very noise on larger code bases. Running it on LLVM: {F5354858} for default configuration {F5354866} just for llvm/lib/Analysis/ScalarEvolution.cpp, the else-path checker is very noisy! Reviewers: alexfh, aaron.ballman, hokein Reviewed By: aaron.ballman Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits, mgorny, JDevlieghere, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D37808 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@318600 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27[clang-tidy] Fix bug 34845, offending standard bitmask typesJonas Toth
Summary: The C++ standard allows implementations to choose the underlying type for bitmask types (e.g. std::ios_base::openmode). MSVC implemented some of them as signed integers resulting in warnings for usual code like `auto dd = std::ios_base::badbit | std::ios_base::failbit;` These false positives were reported in https://bugs.llvm.org/show_bug.cgi?id=34845 The fix allows bitwise |,&,^ for known standard bitmask types under the condition that both operands are such bitmask types. Shifting and bitwise complement are still forbidden. Reviewers: aaron.ballman, alexfh, hokein Reviewed By: aaron.ballman Subscribers: xazax.hun Differential Revision: https://reviews.llvm.org/D39099 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@316767 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03[clang-tidy] Fix bug 34747, streaming operators and hicpp-signed-bitwiseJonas Toth
The bug happened with stream operations, that were not recognized in all cases. Even there were already existing test for streaming classes, they did not catch this bug. Adding the isolated example to the existing tests did not trigger the bug. Therefore i created a new isolated file that did expose the bug indeed. Differential: https://reviews.llvm.org/D38399 reviewed by aaron.ballman git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@314808 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-11[clang-tidy] add more aliases for the hicpp moduleJonas Toth
This patch will introduce even more aliases for the hicpp-module to already existing checks and is a follow up for D30383 finishing the other sections. It fixes a forgotten highlight in hicpp-braces-around-statements.rst, too. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@312901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30[clang-tidy] Improve hicpp-exception-baseclass to handle generic code betterJonas Toth
Summary: This patch is a followup to the first revision D36583, that had problems with generic code and its diagnostic messages, which were found by @lebedev.ri Reviewers: alexfh, aaron.ballman, lebedev.ri, hokein Reviewed By: aaron.ballman, lebedev.ri Subscribers: klimek, sbenza, cfe-commits, JDevlieghere, lebedev.ri, xazax.hun Differential Revision: https://reviews.llvm.org/D37060 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@312134 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-30[clang-tidy] hicpp bitwise operations on signed integersJonas Toth
Summary: This check implements the rule [[ http://www.codingstandard.com/section/5-6-shift-operators/ | 5.6. HIC++ ]] that forbidds bitwise operations on signed integer types. Reviewers: aaron.ballman, hokein, alexfh, Eugene.Zelenko Reviewed By: aaron.ballman Subscribers: cfe-commits, mgorny, JDevlieghere, xazax.hun Differential Revision: https://reviews.llvm.org/D36586 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@312122 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11Add hicpp-exception-baseclass to the HIC++ module.Aaron Ballman
This enforces that throwing an exception in C++ requires that exception to inherit from std::exception. Patch by Jonas Toth. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@310727 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11Implement hicpp-braces-around-statements as an alias to ↵Aaron Ballman
readability-braces-around-statements. Patch by Jonas Toth. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@310707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[clang-tidy] fix for linker errors in hicpp checksJonathan Coe
Speculative fix for linker errors in r299068. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@299070 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[clang-tidy] add aliases for hicpp moduleJonathan Coe
Summary: Add some hicpp checks that can be implmented as alises for existing clang-tidy checks: hicpp-explicit-conversions hicpp-function-size hicpp-named-parameter hicpp-invalid-access-moved hicpp-member-init hicpp-new-delete-operators hicpp-noexcept-move hicpp-special-member-functions hicpp-undelegated-constructor hicpp-use-equals-default hicpp-use-equals-delete hicpp-use-override Reviewers: dberlin, jbcoe, aaron.ballman, alexfh Reviewed By: aaron.ballman Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D30383 Patch By: Jonas Toth git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@299068 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-19Rename the clang-tidy safety module to be hicpp, for the High-Integrity C++ ↵Aaron Ballman
coding standard from PRQA. This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@298229 91177308-0d34-0410-b5e6-96231b3b80d8