[clang-tools-extra] r214307 - Don't warn on NewCallback argument comments, as they are arguments for the
Alexander Kornienko
alexfh at google.com
Wed Jul 30 07:31:36 PDT 2014
Author: alexfh
Date: Wed Jul 30 09:31:36 2014
New Revision: 214307
URL: http://llvm.org/viewvc/llvm-project?rev=214307&view=rev
Log:
Don't warn on NewCallback argument comments, as they are arguments for the
function the callback points to.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4722
Modified:
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=214307&r1=214306&r2=214307&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Wed Jul 30 09:31:36 2014
@@ -8,9 +8,6 @@
//===----------------------------------------------------------------------===//
#include "ArgumentCommentCheck.h"
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
@@ -25,7 +22,15 @@ ArgumentCommentCheck::ArgumentCommentChe
: IdentRE("^(/\\* *)([_A-Za-z][_A-Za-z0-9]*)( *= *\\*/)$") {}
void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(callExpr(unless(operatorCallExpr())).bind("expr"), this);
+ Finder->addMatcher(
+ callExpr(unless(operatorCallExpr()),
+ // NewCallback's arguments relate to the pointed function, don't
+ // check them against NewCallback's parameter names.
+ // FIXME: Make this configurable.
+ unless(hasDeclaration(functionDecl(anyOf(
+ hasName("NewCallback"), hasName("NewPermanentCallback"))))))
+ .bind("expr"),
+ this);
Finder->addMatcher(constructExpr().bind("expr"), this);
}
Modified: clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp?rev=214307&r1=214306&r2=214307&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp Wed Jul 30 09:31:36 2014
@@ -1,21 +1,29 @@
-// RUN: clang-tidy --checks='-*,misc-argument-comment' %s -- | FileCheck %s
+// RUN: clang-tidy --checks='-*,misc-argument-comment' %s -- -std=c++11 | FileCheck %s -implicit-check-not='{{warning:|error:}}'
// FIXME: clang-tidy should provide a -verify mode to make writing these checks
// easier and more accurate.
-// CHECK-NOT: warning
-
-void f(int x, int y);
-
void ffff(int xxxx, int yyyy);
+void f(int x, int y);
void g() {
// CHECK: [[@LINE+5]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
- // CHECK: :8:12: note: 'x' declared here
+ // CHECK: :[[@LINE-3]]:12: note: 'x' declared here
// CHECK: [[@LINE+3]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
- // CHECK: :8:19: note: 'y' declared here
+ // CHECK: :[[@LINE-5]]:19: note: 'y' declared here
// CHECK-NOT: warning
f(/*y=*/0, /*z=*/0);
}
-// CHECK-NOT: warning
+struct Closure {};
+
+template <typename T1, typename T2>
+Closure *NewCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return nullptr; }
+
+template <typename T1, typename T2>
+Closure *NewPermanentCallback(void (*f)(T1, T2), T1 arg1, T2 arg2) { return nullptr; }
+
+void h() {
+ (void)NewCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
+ (void)NewPermanentCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
+}
More information about the cfe-commits
mailing list