[PATCH] D128372: [Clang-Tidy] Empty Check

Abraham Corea Diaz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 15:00:42 PDT 2022


abrahamcd added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp:177-178
+      diag(NonMemberLoc, "ignoring the result of '%0', did you mean 'clear()'?")
+          << llvm::dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
+                 ->getQualifiedNameAsString()
+          << FixItHint::CreateReplacement(ReplacementRange, ReplacementText);
----------------
njames93 wrote:
> Diagnostics can accept args as `const NamedDecl *`, so you can omit the call to `getQualifiedNameAsString()`.
> The use of `dyn_cast` here is suspicious. If the CalleeDecl isn't a `NamedDecl`, this would assert when you try and call `getQualifiedNameAsString`, but equally I can't see any case why the CalleeDecl wouldn't be a `NamedDecl`. @rsmith Can you think of any situation where this could happen?
Seems that without `getQualifiedNameAsString()` I get longer less-readable versions of the name, e.g. `'empty<std::vector<int> &>'` instead of just `'std::empty'`. Do you think the extra information is helpful here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128372



More information about the cfe-commits mailing list