[PATCH] D39367: [clang-tidy] Add support for operator new[] in check bugprone-misplaced-operator-in-strlen-in-alloc

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 04:31:03 PDT 2017


JonasToth added inline comments.


================
Comment at: clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp:62
+  const Expr *Alloc = Result.Nodes.getNodeAs<CallExpr>("Alloc");
+  if (!Alloc) Alloc = Result.Nodes.getNodeAs<CXXNewExpr>("Alloc");
   const auto *StrLen = Result.Nodes.getNodeAs<CallExpr>("StrLen");
----------------
Break after if condition. You could use the ternary operator, too.

Maybe a safeguard assertion if `Alloc` is nullptr after the second assignemt. This would uncover a potential bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D39367





More information about the cfe-commits mailing list