clang 18.0.0git
|
Models a value of struct
or class
type.
More...
#include "clang/Analysis/FlowSensitive/Value.h"
Public Member Functions | |
RecordValue (RecordStorageLocation &Loc) | |
RecordStorageLocation & | getLoc () const |
Returns the storage location that this RecordValue is associated with. | |
![]() | |
Value (Kind ValKind) | |
Value (const Value &)=delete | |
Value & | operator= (const Value &)=delete |
virtual | ~Value ()=default |
Kind | getKind () const |
Value * | getProperty (llvm::StringRef Name) const |
Returns the value of the synthetic property with the given Name or null if the property isn't assigned a value. | |
void | setProperty (llvm::StringRef Name, Value &Val) |
Assigns Val as the value of the synthetic property with the given Name . | |
llvm::iterator_range< llvm::StringMap< Value * >::const_iterator > | properties () const |
Static Public Member Functions | |
static bool | classof (const Value *Val) |
Additional Inherited Members | |
![]() | |
enum class | Kind { Integer , Pointer , Record , TopBool , AtomicBool , FormulaBool } |
Models a value of struct
or class
type.
In C++, prvalues of class type serve only a limited purpose: They can only be used to initialize a result object. It is not possible to access member variables or call member functions on a prvalue of class type. Correspondingly, RecordValue
also serves only two limited purposes:
It conveys a prvalue of class type from the place where the object is constructed to the result object that it initializes.
When creating a prvalue of class type, we already need a storage location for this
, even though prvalues are otherwise not associated with storage locations. RecordValue
is therefore essentially a wrapper for a storage location, which is then used to set the storage location for the result object when we process the AST node for that result object.
For example: MyStruct S = MyStruct(3);
In this example, MyStruct(3) is a prvalue, which is modeled as a
RecordValuethat wraps a
RecordStorageLocation`. This
RecordValue
in place, as these changes would be visible to other Environment
s that share the same RecordValue
. Instead, associate a new RecordValue
with the RecordStorageLocation
and set the properties on this new RecordValue
. (See also refreshRecordValue()
in DataflowEnvironment.h, which makes this easy.) Note also that this implies that it is common for the same RecordStorageLocation
to be associated with different RecordValue
s in different environments. Over time, we may eliminate RecordValue
entirely. See also the discussion here: https://reviews.llvm.org/D155204#inline-1503204
|
inlineexplicit |
Definition at line 221 of file Value.h.
References clang::dataflow::Value::getKind(), and clang::dataflow::Value::Record.
|
inline |
Returns the storage location that this RecordValue
is associated with.