[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 28 04:54:33 PDT 2019


Szelethus marked 2 inline comments as done.
Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:378-379
+
+  using CheckFn = void (MallocChecker::*)(CheckerContext &C, const CallExpr *CE,
+                                          ProgramStateRef State) const;
+
----------------
NoQ wrote:
> Whenever i see a (`CE`, `State`) pair, it screams `CallEvent` to me. That said, i'm worried that `State` in these callbacks isn't necessarily equal to `C.getState()` (the latter, by the way, is always equal to the `CallEvent`'s `.getState()` - that's a relief, right?), so if you'll ever be in the mood to check that, that'd be great :)
It should be always equal to it. I'll change it.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:397-398
+  CallDescriptionMap<CheckFn> NonFreeingMemFnMap{
+      {{"alloca", 1}, &MallocChecker::checkAlloca},
+      {{"_alloca", 1}, &MallocChecker::checkAlloca},
+      {{"malloc", 1}, &MallocChecker::checkMalloc},
----------------
NoQ wrote:
> I think `alloca` deserves `CDF_MaybeBuiltin`. This would also probably allow you to remove the second line.
Actually, `BuiltinFunctionChecker` uses `evalCall` to create an `AllocaRegion` for `__builtin_alloca`. I spent an hour when writing this patch to track a crash down when I initially made this `CDF_MaybeBuiltin` :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68165





More information about the cfe-commits mailing list