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

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 26 05:23:16 PDT 2020


balazske marked an inline comment as done.
balazske added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:396
+  /// yes was the value obtained or not.
+  mutable Optional<Optional<int>> KernelZeroSizePtrValue;
+
----------------
martong wrote:
> balazske wrote:
> > martong wrote:
> > > 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<...>>
> > > ```
> > Probably use a `std::unique_ptr<Optional<int>>` instead (like at the bug types, they could be optional too)?
> > If there is a code like
> > ```
> > bool IsSomethingInitialized;
> > int Something;
> > ```
> > that looks as a clear case to use an optional (or unique_ptr)? And if yes, is a reason for not using this construct if `int` is replaced by `Optional<int>`?
> Now I see that the lazy initialization is represented by the outer optional.
> So IMHO a using template could be the best to describe cleanly this construct:
> ```
> template <class T>
> using LazyInitialized = Optional<T>;
> mutable LazyInitialized<Optional<int>> KernelZeroSizePtrValue;
> ```
> 
With this I would wait for opinion of somebody else.


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