18#define DEBUG_TYPE "dataflow"
25 assert(Field.getType()->isReferenceType() ||
26 (SrcFieldLoc !=
nullptr && DstFieldLoc !=
nullptr));
28 if (Field.getType()->isRecordType()) {
31 }
else if (Field.getType()->isReferenceType()) {
60 auto DstDecl = DstType->getAsCXXRecordDecl();
65 [[maybe_unused]]
bool CompatibleTypes =
67 (SrcDecl !=
nullptr && DstDecl !=
nullptr &&
68 (SrcDecl->isDerivedFrom(DstDecl) || DstDecl->isDerivedFrom(SrcDecl) ||
69 (DeclToCopy !=
nullptr && SrcDecl->
isDerivedFrom(DeclToCopy) &&
70 DstDecl->isDerivedFrom(DeclToCopy))));
73 if (!CompatibleTypes) {
74 llvm::dbgs() <<
"Source type " << Src.
getType() <<
"\n";
75 llvm::dbgs() <<
"Destination type " << Dst.
getType() <<
"\n";
78 assert(CompatibleTypes);
80 if (SrcType == DstType || (SrcDecl !=
nullptr && DstDecl !=
nullptr &&
81 SrcDecl->isDerivedFrom(DstDecl))) {
82 for (
auto [Field, DstFieldLoc] : Dst.
children())
87 }
else if (SrcDecl !=
nullptr && DstDecl !=
nullptr &&
88 DstDecl->isDerivedFrom(SrcDecl)) {
89 for (
auto [Field, SrcFieldLoc] : Src.
children())
99 for (
const auto &[SyntheticFieldName, SyntheticFieldType] :
113 llvm::dbgs() <<
"Loc1 type " << Loc1.
getType() <<
"\n";
114 llvm::dbgs() <<
"Loc2 type " << Loc2.
getType() <<
"\n";
120 for (
auto [Field, FieldLoc1] : Loc1.
children()) {
123 assert(Field->getType()->isReferenceType() ||
124 (FieldLoc1 !=
nullptr && FieldLoc2 !=
nullptr));
126 if (Field->getType()->isRecordType()) {
130 }
else if (Field->getType()->isReferenceType()) {
131 if (FieldLoc1 != FieldLoc2)
139 if (SynthFieldLoc1->getType()->isRecordType()) {
144 }
else if (Env1.
getValue(*SynthFieldLoc1) !=
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
C Language Family Type Representation.
Represents a C++ struct/union/class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a member of a struct/union/class.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isRecordType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
llvm::StringMap< QualType > getSyntheticFields(QualType Type)
Returns the names and types of the synthetic fields for the given record type.
FieldSet getModeledFields(QualType Type)
Returns the fields of Type, limited to the set of fields modeled by this context.
Holds the state of the program (store and heap) at a given program point.
void clearValue(const StorageLocation &Loc)
Clears any association between Loc and a value in the environment.
Value * getValue(const StorageLocation &Loc) const
Returns the value assigned to Loc in the environment or null if Loc isn't assigned a value in the env...
DataflowAnalysisContext & getDataflowAnalysisContext() const
Returns the DataflowAnalysisContext used by the environment.
void setValue(const StorageLocation &Loc, Value &Val)
Assigns Val as the value of Loc in the environment.
A storage location for a record (struct, class, or union).
llvm::iterator_range< SyntheticFieldMap::const_iterator > synthetic_fields() const
StorageLocation * getChild(const ValueDecl &D) const
Returns the child storage location for D.
void setChild(const ValueDecl &D, StorageLocation *Loc)
Changes the child storage location for a field D of reference type.
StorageLocation & getSyntheticField(llvm::StringRef Name) const
Returns the storage location for the synthetic field Name.
llvm::iterator_range< FieldToLoc::const_iterator > children() const
Base class for elements of the local variable store and of the heap.
Base class for all values computed by abstract interpretation.
Dataflow Directional Tag Classes.
void copyRecord(RecordStorageLocation &Src, RecordStorageLocation &Dst, Environment &Env, QualType TypeToCopy=QualType())
Copies a record (struct, class, or union) from Src to Dst.
bool recordsEqual(const RecordStorageLocation &Loc1, const Environment &Env1, const RecordStorageLocation &Loc2, const Environment &Env2)
Returns whether the records Loc1 and Loc2 are equal.
static void copyField(const ValueDecl &Field, StorageLocation *SrcFieldLoc, StorageLocation *DstFieldLoc, RecordStorageLocation &Dst, Environment &Env)
static void copySyntheticField(QualType FieldType, StorageLocation &SrcFieldLoc, StorageLocation &DstFieldLoc, Environment &Env)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)