[PATCH] D57674: [clang-tidy] Add options to bugprone-argument-comment to add missing argument comments to literals

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 5 13:08:28 PST 2019


MyDeveloperDay added inline comments.


================
Comment at: clang-tidy/bugprone/ArgumentCommentCheck.cpp:228-236
+static bool isStringLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast<ImplicitCastExpr>(Arg);
+  return Cast ? isa<StringLiteral>(Cast->getSubExpr()) : false;
+}
+
+static bool isNullPtrLiteral(const Expr *Arg) {
+  const auto *Cast = dyn_cast<ImplicitCastExpr>(Arg);
----------------
aaron.ballman wrote:
> What's going on with these? Why not `return isa<Blah>(Arg->IgnoreImpCasts());` (at which point, no need for the separate functions).
OK, my bad, I was just looking at the ast-dump on godbolt.org thinking... how do I get past that ImplicitCasrExpr, learning these tricks in the AST isn't always obvious despite me looking in doxygen, when you don't know what to look for its hard to know..but this is a neat trick and I'm happy to learn.


================
Comment at: docs/clang-tidy/checks/bugprone-argument-comment.rst:40
+
+  void foo(bool turn_key,bool press_button);
+
----------------
aaron.ballman wrote:
> aaron.ballman wrote:
> > Format the code examples from our style guide as well (same below).
> This still seems to be happening in the current revision?
Sorry didn't catch your meaning but I assume it was the space between the arguments...


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

https://reviews.llvm.org/D57674





More information about the cfe-commits mailing list