[clang] [analyzer][NFC] Add some docs for LazyCompoundValue (PR #97407)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 06:17:24 PDT 2024


================
@@ -346,6 +352,39 @@ class CompoundVal : public NonLoc {
   static bool classof(SVal V) { return V.getKind() == CompoundValKind; }
 };
 
+/// The simplest example of a concrete compound value is nonloc::CompoundVal,
+/// which represents a concrete r-value of an initializer-list or a string.
+/// Internally, it contains an llvm::ImmutableList of SVal's stored inside the
+/// literal.
+///
+/// However, there is another compound value used in the analyzer, which appears
+/// much more often during analysis, which is nonloc::LazyCompoundVal. This
+/// value is an r-value that represents a snapshot of any structure "as a whole"
+/// at a given moment during the analysis. Such value is already quite far from
+/// being re- ferred to as "concrete", as many fields inside it would be unknown
+/// or symbolic. nonloc::LazyCompoundVal operates by storing two things:
+///   * a reference to the TypedValueRegion being snapshotted (yes, it is always
+///     typed), and also
+///   * a copy of the whole Store object, obtained from the ProgramState in
----------------
NagyDonat wrote:

Is it truly a _copy_ of the store object? This seems to contradict the "is a very cheap operation" line in the next paragraph...?

Or is it a _copied store object_ that _shares the same bulk allocations_ with the original one (but differs in minor details?) 

https://github.com/llvm/llvm-project/pull/97407


More information about the cfe-commits mailing list