aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-11[clang-tidy][NFC] add '.clang-tidy' config for clang-tidy project (#147793)Baranov Victor1-1/+1
Added `.clang-tidy` config as discussed in [RFC](https://discourse.llvm.org/t/rfc-create-hardened-clang-tidy-config-for-clang-tidy-directory/87247). Added `bugprone`, `readability`, `modernize`, `performance` checks that didn't create many warnings. Fixed minor warnings to make `/clang-tidy` directory complaint with `clang-tidy-20`. Disabled checks will be enabled in future PRs after fixing their warnings.
2023-12-13[clang-tidy] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-01-14[clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folderCarlos Galvez1-6/+2
Fix applied by running: run-clang-tidy.py -checks=-*,modernize-concat-nested-namespaces Differential Revision: https://reviews.llvm.org/D141770
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille1-2/+2
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2022-06-20[clang-tidy] bugprone-argument-comment: Ignore calls to user-defined literalsJoachim Priesner1-1/+1
Without this change, code such as "f(/*param=*/1_op)" will check the comment twice, once for the parameter of f (correct) and once for the parameter of operator""_op (likely incorrect). The change removes only the second check. Reviewed By: njames93, LegalizeAdulthood Differential Revision: https://reviews.llvm.org/D125885
2021-10-13bugprone-argument-comment: SourceLocation valid judgment avoid emitting ↵liuke1-0/+2
coredump in isInSystemHeader If the Node has an invalid location, it will trigger assert in isInSystemHeader(...). void test() { __builtin_va_list __args; // __builtin_va_list has no defination in any source file and its // CXXConstructorDecl has invalid sourcelocation } coredump with "Assertion `Loc.isValid() && "Can't get file characteristic of invalid loc!"' failed." in getFileCharacteristic(SourceLocation).
2021-08-03bugprone-argument-comment: ignore mismatches from system headersGeorge Burgess IV1-8/+10
As of 2a3498e24f97d, we ignore parameter name mismatches for functions in the `std::` namespace, since those aren't standardized. It seems reasonable to extend this to all functions which are declared in system headers, since this lint can be a bit noisy otherwise (https://bugs.chromium.org/p/chromium/issues/detail?id=1191507). Differential Revision: https://reviews.llvm.org/D99993
2021-06-25[clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()Martin Storsjö1-2/+2
2021-01-29[clang-tidy] Applied clang-tidy fixes. NFCAlexander Kornienko1-1/+1
Applied fixes enabled by the LLVM's .clang-tidy configs. Reverted files where fixes introduced compile errors: clang-tools-extra/clang-tidy/hicpp/NoAssemblerCheck.cpp clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp $ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -fix clang-tools-extra/clang-tidy/ Enabled checks: llvm-else-after-return llvm-header-guard llvm-include-order llvm-namespace-comment llvm-prefer-isa-or-dyn-cast-in-conditionals llvm-prefer-register-over-unsigned llvm-qualified-auto llvm-twine-local misc-definitions-in-headers misc-misplaced-const misc-new-delete-overloads misc-no-recursion misc-non-copyable-objects misc-redundant-expression misc-static-assert misc-throw-by-value-catch-by-reference misc-unconventional-assign-operator misc-uniqueptr-reset-release misc-unused-alias-decls misc-unused-using-decls readability-identifier-naming Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D95614
2020-05-07[clang-tidy] Exclude function calls in std namespace for ↵Haojian Wu1-2/+17
bugprone-argument-comment. Reviewers: gribozavr2 Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79494
2020-04-12[clang-tidy] Convert config options that are bools to use the bool overload ↵Nathan James1-10/+10
of get(GlobalOrLocal)? Summary: This was done with a script that looks for calls to Options.get(GlobalOrLocal) that take an integer for the second argument and the result is either compared not equal to 0 or implicitly converted to bool. There may be other occurances Reviewers: aaron.ballman, alexfh, gribozavr2 Reviewed By: aaron.ballman Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77831
2019-09-23Removed an incorred namespace-end commentDmitri Gribenko1-1/+1
llvm-svn: 372593
2019-09-19[clang-tidy] Fix bugprone-argument-comment-check to correctly ignore ↵Yitzhak Mandelbaum1-1/+1
implicit constructors. Summary: After revision 370919, this check incorrectly flags certain cases of implicit constructors. Specifically, if an argument is annotated with an argument-comment and the argument expression triggers an implicit constructor, then the argument comment is associated with argument of the implicit constructor. However, this only happens when the constructor has more than one argument. This revision fixes the check for implicit constructors and adds a regression test for this case. Note: r370919 didn't cause this bug, it simply uncovered it by fixing another bug that was masking the behavior. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67744 llvm-svn: 372317
2019-09-05[clang-tidy] Make most ArgumentCommentCheck options local, as they should beAlexander Kornienko1-13/+8
llvm-svn: 371076
2019-09-05Add a bugprone-argument-comment option: IgnoreSingleArgument.Alexander Kornienko1-1/+3
Summary: Add bugprone-argument-comment option: IgnoreSingleArgument. When true, the check will ignore the single argument. Sometimes, it's not necessary to add comment to single argument. For example: > std::string name("Yubo Xie"); > pScreen->SetWidth(1920); > pScreen->SetHeight(1080); This option can ignore such single argument in bugprone-argument-comment check. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits Tags: #clang Patch by Yubo Xie. Differential Revision: https://reviews.llvm.org/D67056 llvm-svn: 371075
2019-09-05[clang-tidy] Fix bugprone-argument-comment bug: negative literal number is ↵Alexander Kornienko1-1/+3
not checked. Summary: For example: ``` void foo(int a); foo(-2); ``` should be fixed as: ``` foo(/*a=*/-2); ``` This change tries to fix this issue. Reviewers: alexfh, hokein, aaron.ballman Reviewed By: alexfh, aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Patch by Yubo Xie. Differential Revision: https://reviews.llvm.org/D67084 llvm-svn: 371072
2019-09-04[clang-tidy] Fix bugprone-argument-comment bug if there are marcos.Alexander Kornienko1-2/+2
Summary: Fix bugprone-argument-comment bug if there are marcos. For example: ``` void j(int a, int b, int c); j(X(1), /*b=*/1, X(1)); ``` clang-tidy can't recognize comment "/*b=*/". It suggests fix like this: ``` j(X(1), /*b=*//*b=*/1, X(1)); ``` This change tries to fix this issue. Reviewers: alexfh, hokein, aaron.ballman Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Patch by Yubo Xie. Differential Revision: https://reviews.llvm.org/D67080 llvm-svn: 370919
2019-02-08[clang-tidy] Add options to bugprone-argument-comment to add missing ↵Paul Hoad1-10/+57
argument comments to literals bugprone-argument-comment only supports identifying those comments which do not match the function parameter name This revision add 3 options to adding missing argument comments to literals (granularity on type is added to control verbosity of fixit) ``` CheckOptions: - key: bugprone-argument-comment.CommentBoolLiterals value: '1' - key: bugprone-argument-comment.CommentFloatLiterals value: '1' - key: bugprone-argument-comment.CommentIntegerLiterals value: '1' - key: bugprone-argument-comment.CommentStringLiterals value: '1' - key: bugprone-argument-comment.CommentCharacterLiterals value: '1' - key: bugprone-argument-comment.CommentUserDefinedLiterals value: '1' - key: bugprone-argument-comment.CommentNullPtrs value: '1' ``` After applying these options, literal arguments will be preceded with /*ParameterName=*/ Reviewers: JonasToth, Eugene.Zelenko, alexfh, hokein, aaron.ballman Reviewed By: aaron.ballman, Eugene.Zelenko Differential Revision: https://reviews.llvm.org/D57674 llvm-svn: 353535
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-10-05[clang-tidy] NFC refactor lexer-utils to be usable without ASTContextJonas Toth1-2/+3
Summary: This patch is a small refactoring necessary for 'readability-isolate-declaration' and does not introduce functional changes. It allows to use the utility functions without a full `ASTContext` and requires only the `SourceManager` and the `LangOpts`. Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52684 llvm-svn: 343850
2018-08-09Port getLocEnd -> getEndLocStephen Kelly1-3/+3
Subscribers: nemanjai, ioeric, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D50355 llvm-svn: 339401
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-2/+2
Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
2017-11-23[clang-tidy] rename_check.py misc-argument-comment bugprone-argument-commentAlexander Kornienko1-0/+308
Summary: + manually convert the unit test to lit test. Reviewers: hokein Reviewed By: hokein Subscribers: mgorny, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40392 llvm-svn: 318926