[PATCH] D20689: [clang-tidy] Add 'readability-suspicious-call-argument' check

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 28 03:04:58 PDT 2021


whisperity marked 12 inline comments as done.
whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:408-409
+
+  bool IsParamContinuouslyConst =
+      !IsParamReference || ParamType.getNonReferenceType().isConstQualified();
+
----------------
aaron.ballman wrote:
> Should this move down closer to where it's used?
Sure!


================
Comment at: clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp:801
+  }
+  llvm_unreachable("Unhandled heuristic kind");
+}
----------------
aaron.ballman wrote:
> This looks pretty reachable to me in the case where there's no bound.
I'm not sure if that is the case. I added the `llvm_unreachable` so we don't get a warning about the function not having a return value on every code path. The `switch` covers **all** potential heuristics that are in the check //right now//, but if we add a new heuristic (to the enum) and forget to write it in, we will get a `-Wswitch` warning here. A `default` case doesn't apply here, further developers should be encouraged to wire new heuristics in properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D20689



More information about the cfe-commits mailing list