[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

Nicolas van Kempen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 6 07:23:43 PDT 2021


nicovank added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:294
+  } else {
+    if ((MakeCall ? MakeCall->getNumArgs() : CtorCall->getNumArgs()) == 0) {
+      Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
----------------
kuhar wrote:
> Can you pull this ternary expression into a variable so that it does not have to repeated when the diagnostic is emitted?
This is a bit tricky, since `MakeCall` is a `CallExpr` and `CtorCall` is a `CXXConstructExpr`, and they have no common base class. Even if I pull it out it'll be a lot of repetition.

I think there may be some elegant way to join the previous removal hints with these, but haven't had time to think about it. I'll probably post another update by the end of this week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101471



More information about the cfe-commits mailing list