[PATCH] D99993: [clang-tidy] bugprone-argument-comment: ignore name mismatches for decls from system headers

George Burgess IV via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 6 15:37:37 PDT 2021


george.burgess.iv added a comment.

Thanks for the comment!

> Why `--header-filter` command line option or `HeaderFilterRegex` configuration file option could not solve this problem?

AFAICT, `--header-filter` & `HeaderFilterRegex` exist to filter diagnostics that occur in matching headers. These diagnostics are influenced by the contents of system headers, but are ultimately emitted inside of source files that have interesting lints, e.g.,

  [ub] /l [ 19ms ] ~> cat test.cpp
  #include <string.h>
  void foo(void *a, const void *b, size_t n) {
    memcpy(/*blah=*/a, b, n);
  }
  [ub] /l [ 2ms ] ~> clang-tidy --checks='bugprone-argument-comment' test.cpp --header-filter='dont-match-anything' --
  1 warning generated.
  /l/test.cpp:3:10: warning: argument name 'blah' in comment does not match parameter name '__dest' [bugprone-argument-comment]
    memcpy(/*blah=*/a, b, n);
           ^
  /usr/include/string.h:43:39: note: '__dest' declared here
  extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
                                        ^
  [ub] /l [ 25ms ] ~> clang-tidy --checks='bugprone-argument-comment' test.cpp --config 'HeaderFilterRegex: "dont-match-anything"' --
  1 warning generated.
  /l/test.cpp:3:10: warning: argument name 'blah' in comment does not match parameter name '__dest' [bugprone-argument-comment]
    memcpy(/*blah=*/a, b, n);
           ^
  /usr/include/string.h:43:39: note: '__dest' declared here
  extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
                                        ^
  [ub] /l [ 22ms ] ~> 

So I don't think those help here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99993/new/

https://reviews.llvm.org/D99993



More information about the cfe-commits mailing list