[PATCH] D75432: [analyzer][NFC][MallocChecker] Convert many parameters into CallEvent

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 3 05:39:02 PST 2020


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


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:995
 
-void MallocChecker::checkBasicAlloc(CheckerContext &C, const CallExpr *CE,
-                                    ProgramStateRef State) const {
-  State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State, AF_Malloc);
-  State = ProcessZeroAllocCheck(C, CE, 0, State);
+void MallocChecker::checkBasicAlloc(const CallEvent &Call,
+                                    CheckerContext &C) const {
----------------
xazax.hun wrote:
> What is the main reason of getting rid of the state parameter? I think this could make using these functions more error prone overall as it would be easier to introduce splits in the exploded graph this way (if we somehow wanted to model a function as successive calls of some other functions).
Refer to @NoQ's [[https://reviews.llvm.org/D68165?id=222257#inline-612842|earlier inline]].

> I think this could make using these functions more error prone overall as it would be easier to introduce splits in the exploded graph this way (if we somehow wanted to model a function as successive calls of some other functions).

Why would the removal of a `ProgramStateRef` parameter cause that?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1641
 ProgramStateRef MallocChecker::FreeMemAux(
-    CheckerContext &C, const Expr *ArgExpr, const Expr *ParentExpr,
     ProgramStateRef State, bool Hold, bool &IsKnownToBeAllocated,
----------------
xazax.hun wrote:
> In functions where we only use `ArgExpr` to retrieve the corresponding `SVal` we could pass the `SVal` in the first place.
Long term, I plan to find a better value type for the `CallDescriptionMap` where information such as this could be retrieved easier, which is why I focused on nothing but the task at hand.

While I would like to see `MallocChecker` in a healthier state, at times I find the development effort I'm putting into it questionable, so I'll probably stop at the point where I can comfortably split it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75432





More information about the cfe-commits mailing list