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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 06:08:35 PDT 2017


aaron.ballman added inline comments.


================
Comment at: clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp:64-65
+    Alloc = Result.Nodes.getNodeAs<CXXNewExpr>("Alloc");
+  assert(Alloc && "Matched node bound by `Alloc` shoud be either `CallExpr`"
+         " or `CXXNewExpr`");
+
----------------
The backticks should be single quotes instead, I think.


================
Comment at: test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.cpp:37
+  // CHECK-FIXES: {{^  char \*new_name = new char\[}}std::strlen(name) + 1{{\];$}}
+}
----------------
Please add tests showing that the correct behavior does not diagnose. Also, please add a test showing that this works with overloaded `operator new[]()`.


https://reviews.llvm.org/D39367





More information about the cfe-commits mailing list