clang 19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::dataflow::RecordStorageLocation Class Referencefinal

A storage location for a record (struct, class, or union). More...

#include "clang/Analysis/FlowSensitive/StorageLocation.h"

Inheritance diagram for clang::dataflow::RecordStorageLocation:
Inheritance graph

Public Types

using FieldToLoc = llvm::DenseMap< const ValueDecl *, StorageLocation * >
using SyntheticFieldMap = llvm::StringMap< StorageLocation * >
- Public Types inherited from clang::dataflow::StorageLocation
enum class  Kind { Scalar , Record }

Public Member Functions

 RecordStorageLocation (QualType Type, FieldToLoc TheChildren, SyntheticFieldMap TheSyntheticFields)
StorageLocationgetChild (const ValueDecl &D) const
 Returns the child storage location for D.
StorageLocationgetSyntheticField (llvm::StringRef Name) const
 Returns the storage location for the synthetic field Name.
llvm::iterator_range< SyntheticFieldMap::const_iterator > synthetic_fields () const
void setChild (const ValueDecl &D, StorageLocation *Loc)
 Changes the child storage location for a field D of reference type.
llvm::iterator_range< FieldToLoc::const_iterator > children () const
- Public Member Functions inherited from clang::dataflow::StorageLocation
 StorageLocation (Kind LocKind, QualType Type)
 StorageLocation (const StorageLocation &)=delete
StorageLocationoperator= (const StorageLocation &)=delete
virtual ~StorageLocation ()=default
Kind getKind () const
QualType getType () const

Static Public Member Functions

static bool classof (const StorageLocation *Loc)

Detailed Description

A storage location for a record (struct, class, or union).

Contains storage locations for all modeled fields of the record (also referred to as "children"). The child map is flat, so accessible members of the base class are directly accessible as children of this location.

Record storage locations may also contain so-called synthetic fields. These are typically used to model the internal state of a class (e.g. the value stored in a std::optional) without having to depend on that class's implementation details. All RecordStorageLocations of a given type should have the same synthetic fields.

The storage location for a field of reference type may be null. This typically occurs in one of two situations:

FIXME: Currently, the storage location of unions is modelled the same way as that of structs or classes. Eventually, we need to change this modelling so that all of the members of a given union have the same storage location.

Definition at line 94 of file StorageLocation.h.

Member Typedef Documentation

◆ FieldToLoc

Definition at line 96 of file StorageLocation.h.

◆ SyntheticFieldMap

Definition at line 97 of file StorageLocation.h.

Constructor & Destructor Documentation

◆ RecordStorageLocation()

clang::dataflow::RecordStorageLocation::RecordStorageLocation ( QualType  Type,
FieldToLoc  TheChildren,
SyntheticFieldMap  TheSyntheticFields 

Definition at line 99 of file StorageLocation.h.

References clang::Type::isRecordType(), and Loc.

Member Function Documentation

◆ children()

llvm::iterator_range< FieldToLoc::const_iterator > clang::dataflow::RecordStorageLocation::children ( ) const

◆ classof()

static bool clang::dataflow::RecordStorageLocation::classof ( const StorageLocation Loc)

Definition at line 114 of file StorageLocation.h.

References Loc, and clang::dataflow::StorageLocation::Record.

◆ getChild()

StorageLocation * clang::dataflow::RecordStorageLocation::getChild ( const ValueDecl D) const

Returns the child storage location for D.

May return null if D has reference type; guaranteed to return non-null in all other cases.

Note that it is an error to call this with a field that does not exist. The function does not return null in this case.

Definition at line 125 of file StorageLocation.h.

Referenced by clang::dataflow::builtinTransferInitializer(), clang::dataflow::copyRecord(), and clang::dataflow::recordsEqual().

◆ getSyntheticField()

StorageLocation & clang::dataflow::RecordStorageLocation::getSyntheticField ( llvm::StringRef  Name) const

Returns the storage location for the synthetic field Name.

The synthetic field must exist.

Definition at line 144 of file StorageLocation.h.

References Loc.

Referenced by clang::dataflow::copyRecord(), and clang::dataflow::recordsEqual().

◆ setChild()

void clang::dataflow::RecordStorageLocation::setChild ( const ValueDecl D,
StorageLocation Loc 

Changes the child storage location for a field D of reference type.

All other fields cannot change their storage location and always retain the storage location passed to the RecordStorageLocation constructor.


D must have reference type.

Definition at line 162 of file StorageLocation.h.

References clang::ValueDecl::getType(), clang::Type::isReferenceType(), and Loc.

Referenced by clang::dataflow::builtinTransferInitializer(), and clang::dataflow::copyField().

◆ synthetic_fields()

llvm::iterator_range< SyntheticFieldMap::const_iterator > clang::dataflow::RecordStorageLocation::synthetic_fields ( ) const

The documentation for this class was generated from the following file: