Skip to content

Commit

Permalink
[clang][dataflow] Use a PointerValue for value property in option…
Browse files Browse the repository at this point in the history
…al checker.

The `ReferenceValue` class will be eliminated as part of the ongoing migration
to strict handling of value categories (see https://discourse.llvm.org/t/70086
for details).

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D152144
  • Loading branch information
martinboehme committed Jun 5, 2023
1 parent d2d32f3 commit af22be3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ StorageLocation *maybeInitializeOptionalValueMember(QualType Q,
Environment &Env) {
// The "value" property represents a synthetic field. As such, it needs
// `StorageLocation`, like normal fields (and other variables). So, we model
// it with a `ReferenceValue`, since that includes a storage location. Once
// it with a `PointerValue`, since that includes a storage location. Once
// the property is set, it will be shared by all environments that access the
// `Value` representing the optional (here, `OptionalVal`).
if (auto *ValueProp = OptionalVal.getProperty("value")) {
auto *ValueRef = clang::cast<ReferenceValue>(ValueProp);
auto &ValueLoc = ValueRef->getReferentLoc();
auto *ValuePtr = clang::cast<PointerValue>(ValueProp);
auto &ValueLoc = ValuePtr->getPointeeLoc();
if (Env.getValue(ValueLoc) == nullptr) {
// The property was previously set, but the value has been lost. This can
// happen, for example, because of an environment merge (where the two
Expand All @@ -339,8 +339,8 @@ StorageLocation *maybeInitializeOptionalValueMember(QualType Q,
return nullptr;
auto &ValueLoc = Env.createStorageLocation(Ty);
Env.setValue(ValueLoc, *ValueVal);
auto &ValueRef = Env.create<ReferenceValue>(ValueLoc);
OptionalVal.setProperty("value", ValueRef);
auto &ValuePtr = Env.create<PointerValue>(ValueLoc);
OptionalVal.setProperty("value", ValuePtr);
return &ValueLoc;
}

Expand Down

0 comments on commit af22be3

Please sign in to comment.