[PATCH] D76830: [Analyzer][MallocChecker] No warning for kfree of ZERO_SIZE_PTR.

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 26 02:40:33 PDT 2020


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:396
+  /// yes was the value obtained or not.
+  mutable Optional<Optional<int>> KernelZeroSizePtrValue;
+
----------------
Which one is referred to the lazy initialization? The inner or the outer?
These questions actually made me to come up with a more explanatory construct here:
Could we do something like this?
```
using LazyInitialized = Optional<int>;
mutable Optional<LazyInitialized> KernelZeroSizePtrValue; // Or Lazy<Optional<...>>
```


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1687
+  if (ArgValKnown) {
+    if (!KernelZeroSizePtrValue)
+      KernelZeroSizePtrValue =
----------------
This is a bit confusing for me. Perhaps alternatively we could have a free function `isInitialized(KernelZero...)` instead. Or maybe having a separate bool variable to indicate whether it was initialized could be cleaner?


================
Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:146
 
   return IntValue.getSExtValue();
 }
----------------
balazske wrote:
> The function was changed to get the numeric value from the end of the macro in any case. This way it recognizes a `(void *)16` as 16 (but maybe `16+16` too as 16).
Ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76830





More information about the cfe-commits mailing list