[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls
Malcolm Parsons via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 13 02:21:33 PST 2016
malcolm.parsons added inline comments.
================
Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:29
+ Finder->addMatcher(
+ callExpr(callee(functionDecl(hasAnyName("::malloc", "::calloc"))))
+ .bind("aquisition"),
----------------
C memory management functions are also present in the `std` namespace.
================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst:10
+See `C++ Core Guidelines
+<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r-resource-management>`
+
----------------
Do you mean `#r10-avoid-malloc-and-free`?
================
Comment at: docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst:26
+ // Rather use a smartpointer or stack variable.
+ struct some_struct* = (struct some_struct*) malloc(sizeof(struct some_struct));
+
----------------
Missing variable.
Repository:
rL LLVM
https://reviews.llvm.org/D26167
More information about the cfe-commits
mailing list