martong added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1687
+  if (ArgValKnown) {
+    if (!KernelZeroSizePtrValue)
+      KernelZeroSizePtrValue =
----------------
balazske wrote:
> martong wrote:
> > martong wrote:
> > > 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?
> > Another idea: Adding a helper struct to contain the bool `initialized`? 
> > E.g. (draft):
> > ```
> > struct LazyOptional {
> >   bool initialized = false;
> >   Opt<int> value;
> >   Opt& get();
> >   void set(const Opt&);
> > };
> > ```
> It may be OK to have a function `lazyInitKernelZeroSizePtrValue`?
I don't insist, given we have a better described type for 
`KernelZeroSizePtrValue` (e.g. having a `using` `template`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76830



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to