summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2019-09-05 14:13:57 +0000
committerAlexander Kornienko <alexfh@google.com>2019-09-05 14:13:57 +0000
commitb6d9703050d0d9ca903576767bc83df783362186 (patch)
tree547ad98156e269487ddb0db84de1662cf69c34d6 /clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
parent4e14bf71b70b6c1e356b571611d143d8facda86b (diff)
downloadbcm5719-llvm-b6d9703050d0d9ca903576767bc83df783362186.tar.gz
bcm5719-llvm-b6d9703050d0d9ca903576767bc83df783362186.zip
[clang-tidy] Fix bugprone-argument-comment bug: negative literal number is 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
Diffstat (limited to 'clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index 07219f9c724..968333ce15e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -230,9 +230,11 @@ static const FunctionDecl *resolveMocks(const FunctionDecl *Func) {
// Given the argument type and the options determine if we should
// be adding an argument comment.
bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
+ Arg = Arg->IgnoreImpCasts();
+ if (isa<UnaryOperator>(Arg))
+ Arg = cast<UnaryOperator>(Arg)->getSubExpr();
if (Arg->getExprLoc().isMacroID())
return false;
- Arg = Arg->IgnoreImpCasts();
return (CommentBoolLiterals && isa<CXXBoolLiteralExpr>(Arg)) ||
(CommentIntegerLiterals && isa<IntegerLiteral>(Arg)) ||
(CommentFloatLiterals && isa<FloatingLiteral>(Arg)) ||
OpenPOWER on IntegriCloud