diff options
author | Alexander Kornienko <alexfh@google.com> | 2019-09-05 14:48:23 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2019-09-05 14:48:23 +0000 |
commit | ca7bac56dcfe6a86e396492a1284c030c703e0fc (patch) | |
tree | cc89b1ecf64a9ba0a1cb13435713dfdabae4bc53 /clang-tidy/bugprone | |
parent | c3043c8338282cd693a5bdd5c8c00a7974a678ff (diff) |
Add a bugprone-argument-comment option: IgnoreSingleArgument.
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@371075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/bugprone')
-rw-r--r-- | clang-tidy/bugprone/ArgumentCommentCheck.cpp | 4 | ||||
-rw-r--r-- | clang-tidy/bugprone/ArgumentCommentCheck.h | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tidy/bugprone/ArgumentCommentCheck.cpp index 968333ce..9849b65c 100644 --- a/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ b/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -24,6 +24,7 @@ ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0), + IgnoreSingleArgument(Options.get("IgnoreSingleArgument", 0) != 0), CommentBoolLiterals(Options.getLocalOrGlobal("CommentBoolLiterals", 0) != 0), CommentIntegerLiterals( @@ -41,6 +42,7 @@ ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name, void ArgumentCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "StrictMode", StrictMode); + Options.store(Opts, "IgnoreSingleArgument", IgnoreSingleArgument); Options.store(Opts, "CommentBoolLiterals", CommentBoolLiterals); Options.store(Opts, "CommentIntegerLiterals", CommentIntegerLiterals); Options.store(Opts, "CommentFloatLiterals", CommentFloatLiterals); @@ -254,7 +256,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx, Callee = Callee->getFirstDecl(); unsigned NumArgs = std::min<unsigned>(Args.size(), Callee->getNumParams()); - if (NumArgs == 0) + if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1)) return; auto MakeFileCharRange = [Ctx](SourceLocation Begin, SourceLocation End) { diff --git a/clang-tidy/bugprone/ArgumentCommentCheck.h b/clang-tidy/bugprone/ArgumentCommentCheck.h index 216d92c5..0c66ffbd 100644 --- a/clang-tidy/bugprone/ArgumentCommentCheck.h +++ b/clang-tidy/bugprone/ArgumentCommentCheck.h @@ -41,6 +41,7 @@ public: private: const unsigned StrictMode : 1; + const unsigned IgnoreSingleArgument : 1; const unsigned CommentBoolLiterals : 1; const unsigned CommentIntegerLiterals : 1; const unsigned CommentFloatLiterals : 1; |