[PATCH] D59054: [analyzer] C++17: PR40022: Support aggregate initialization with compound values in presence of base classes.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 7 14:15:37 PST 2019
NoQ updated this revision to Diff 189781.
NoQ marked 5 inline comments as done.
NoQ added a comment.
Thx! Also added the more direct test.
> I'll take the time to understand the infrastructure behind it
Well, roughly, the `CompoundVal` kind of value is used very rarely, unlike `LazyCompoundVal`. The raw `CompoundVal` is essentially a symbolic `InitListExpr`: an (immutable) list of other values. It appears pretty much only when there's an actual initializer list expression in the program, and the analyzer tries to unwrap it as soon as possible.
This code is where such unwrap happens: when the compound value is put into the object that it was supposed to initialize (it's an *initializer* list, after all), instead of binding the whole value to the whole object, we bind sub-values to sub-objects. Sub-values may themselves be compound values, and in this case the procedure becomes recursive.
The annoying part about compound values is that they don't carry any sort of information about which value corresponds to which sub-object. It's simply a list of values in the middle of nowhere; the Store expects to match them to sub-objects, essentially, by *index*: first value binds to the first field, second value binds to the second field, etc. The crash was occuring when it was accidentally trying to bind a base-class value to a field object - because it simply didn't know that base objects are a thing.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59054/new/
https://reviews.llvm.org/D59054
Files:
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/array-struct-region.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59054.189781.patch
Type: text/x-patch
Size: 4222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190307/80ac8eb9/attachment.bin>
More information about the cfe-commits
mailing list