[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 04:17:53 PDT 2020
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
More information about the cfe-commits
mailing list