[clang] b244b6a - [clang][dataflow] Remove `Strict` suffix from accessors.
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 31 12:40:21 PDT 2023
Author: Martin Braenne
Date: 2023-07-31T19:40:09Z
New Revision: b244b6ae0b2153521c5e55ff4705a88618f503aa
URL: https://github.com/llvm/llvm-project/commit/b244b6ae0b2153521c5e55ff4705a88618f503aa
DIFF: https://github.com/llvm/llvm-project/commit/b244b6ae0b2153521c5e55ff4705a88618f503aa.diff
LOG: [clang][dataflow] Remove `Strict` suffix from accessors.
For the time being, we're keeping the `Strict` versions around as deprecated synonyms so that clients can be migrated, but these synonyms will be removed soon.
Depends On D156673
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D156674
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index bd89c7e5c74a3c..0e5cfad263c797 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -274,7 +274,12 @@ class Environment {
///
/// `E` must not be assigned a storage location in the environment.
/// `E` must be a glvalue or a `BuiltinType::BuiltinFn`
- void setStorageLocationStrict(const Expr &E, StorageLocation &Loc);
+ void setStorageLocation(const Expr &E, StorageLocation &Loc);
+
+ /// Deprecated synonym for `setStorageLocation()`.
+ void setStorageLocationStrict(const Expr &E, StorageLocation &Loc) {
+ setStorageLocation(E, Loc);
+ }
/// Returns the storage location assigned to the glvalue `E` in the
/// environment, or null if `E` isn't assigned a storage location in the
@@ -285,7 +290,12 @@ class Environment {
///
/// Requirements:
/// `E` must be a glvalue or a `BuiltinType::BuiltinFn`
- StorageLocation *getStorageLocationStrict(const Expr &E) const;
+ StorageLocation *getStorageLocation(const Expr &E) const;
+
+ /// Deprecated synonym for `getStorageLocation()`.
+ StorageLocation *getStorageLocationStrict(const Expr &E) const {
+ return getStorageLocation(E);
+ }
/// Returns the storage location assigned to the `this` pointee in the
/// environment or null if the `this` pointee has no assigned storage location
@@ -442,7 +452,10 @@ class Environment {
/// same as that of any `StructValue` that has already been associated with
/// `E`. This is to guarantee that the result object initialized by a prvalue
/// `StructValue` has a durable storage location.
- void setValueStrict(const Expr &E, Value &Val);
+ void setValue(const Expr &E, Value &Val);
+
+ /// Deprecated synonym for `setValue()`.
+ void setValueStrict(const Expr &E, Value &Val) { setValue(E, Val); }
/// Returns the value assigned to `Loc` in the environment or null if `Loc`
/// isn't assigned a value in the environment.
@@ -585,11 +598,11 @@ class Environment {
// The copy-constructor is for use in fork() only.
Environment(const Environment &) = default;
- /// Internal version of `setStorageLocationStrict()` that doesn't check if the
+ /// Internal version of `setStorageLocation()` that doesn't check if the
/// expression is a prvalue.
void setStorageLocationInternal(const Expr &E, StorageLocation &Loc);
- /// Internal version of `getStorageLocationStrict()` that doesn't check if the
+ /// Internal version of `getStorageLocation()` that doesn't check if the
/// expression is a prvalue.
StorageLocation *getStorageLocationInternal(const Expr &E) const;
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 48f8e63a165efe..503158c91c3f4f 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -337,7 +337,7 @@ Environment Environment::pushCall(const CallExpr *Call) const {
if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
if (!isa<CXXThisExpr>(Arg))
Env.ThisPointeeLoc =
- cast<AggregateStorageLocation>(getStorageLocationStrict(*Arg));
+ cast<AggregateStorageLocation>(getStorageLocation(*Arg));
// Otherwise (when the argument is `this`), retain the current
// environment's `ThisPointeeLoc`.
}
@@ -396,10 +396,10 @@ void Environment::popCall(const CallExpr *Call, const Environment &CalleeEnv) {
if (Call->isGLValue()) {
if (CalleeEnv.ReturnLoc != nullptr)
- setStorageLocationStrict(*Call, *CalleeEnv.ReturnLoc);
+ setStorageLocation(*Call, *CalleeEnv.ReturnLoc);
} else if (!Call->getType()->isVoidType()) {
if (CalleeEnv.ReturnVal != nullptr)
- setValueStrict(*Call, *CalleeEnv.ReturnVal);
+ setValue(*Call, *CalleeEnv.ReturnVal);
}
}
@@ -410,7 +410,7 @@ void Environment::popCall(const CXXConstructExpr *Call,
this->FlowConditionToken = std::move(CalleeEnv.FlowConditionToken);
if (Value *Val = CalleeEnv.getValue(*CalleeEnv.ThisPointeeLoc)) {
- setValueStrict(*Call, *Val);
+ setValue(*Call, *Val);
}
}
@@ -618,8 +618,7 @@ StorageLocation *Environment::getStorageLocation(const ValueDecl &D) const {
return Loc;
}
-void Environment::setStorageLocationStrict(const Expr &E,
- StorageLocation &Loc) {
+void Environment::setStorageLocation(const Expr &E, StorageLocation &Loc) {
// `DeclRefExpr`s to builtin function types aren't glvalues, for some reason,
// but we still want to be able to associate a `StorageLocation` with them,
// so allow these as an exception.
@@ -628,8 +627,8 @@ void Environment::setStorageLocationStrict(const Expr &E,
setStorageLocationInternal(E, Loc);
}
-StorageLocation *Environment::getStorageLocationStrict(const Expr &E) const {
- // See comment in `setStorageLocationStrict()`.
+StorageLocation *Environment::getStorageLocation(const Expr &E) const {
+ // See comment in `setStorageLocation()`.
assert(E.isGLValue() ||
E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
return getStorageLocationInternal(E);
@@ -663,7 +662,7 @@ void Environment::setValue(const StorageLocation &Loc, Value &Val) {
LocToVal[&Loc] = &Val;
}
-void Environment::setValueStrict(const Expr &E, Value &Val) {
+void Environment::setValue(const Expr &E, Value &Val) {
assert(E.isPRValue());
if (auto *StructVal = dyn_cast<StructValue>(&Val)) {
@@ -820,7 +819,7 @@ StorageLocation &Environment::createObjectInternal(const VarDecl *D,
// can happen that we can't see the initializer, so `InitExpr` may still
// be null.
if (InitExpr) {
- if (auto *InitExprLoc = getStorageLocationStrict(*InitExpr))
+ if (auto *InitExprLoc = getStorageLocation(*InitExpr))
return *InitExprLoc;
}
@@ -906,7 +905,7 @@ getImplicitObjectLocation(const CXXMemberCallExpr &MCE,
return nullptr;
}
return cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(*ImplicitObject));
+ Env.getStorageLocation(*ImplicitObject));
}
AggregateStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
@@ -919,8 +918,7 @@ AggregateStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
return &cast<AggregateStorageLocation>(Val->getPointeeLoc());
return nullptr;
}
- return cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(*Base));
+ return cast_or_null<AggregateStorageLocation>(Env.getStorageLocation(*Base));
}
std::vector<FieldDecl *> getFieldsForInitListExpr(const RecordDecl *RD) {
@@ -948,24 +946,24 @@ StructValue &refreshStructValue(const Expr &Expr, Environment &Env) {
if (Expr.isPRValue()) {
if (auto *ExistingVal = cast_or_null<StructValue>(Env.getValue(Expr))) {
auto &NewVal = Env.create<StructValue>(ExistingVal->getAggregateLoc());
- Env.setValueStrict(Expr, NewVal);
+ Env.setValue(Expr, NewVal);
return NewVal;
}
auto &NewVal = *cast<StructValue>(Env.createValue(Expr.getType()));
- Env.setValueStrict(Expr, NewVal);
+ Env.setValue(Expr, NewVal);
return NewVal;
}
if (auto *Loc = cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(Expr))) {
+ Env.getStorageLocation(Expr))) {
auto &NewVal = Env.create<StructValue>(*Loc);
Env.setValue(*Loc, NewVal);
return NewVal;
}
auto &NewVal = *cast<StructValue>(Env.createValue(Expr.getType()));
- Env.setStorageLocationStrict(Expr, NewVal.getAggregateLoc());
+ Env.setStorageLocation(Expr, NewVal.getAggregateLoc());
return NewVal;
}
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index 9b0daf2d95183f..6848127e173e7a 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -260,7 +260,7 @@ class HTMLLogger : public Logger {
JOS->attributeObject(
"value", [&] { ModelDumper(*JOS, State.Env).dump(*V); });
} else {
- if (auto *Loc = State.Env.getStorageLocationStrict(*E))
+ if (auto *Loc = State.Env.getStorageLocation(*E))
JOS->attributeObject(
"value", [&] { ModelDumper(*JOS, State.Env).dump(*Loc); });
}
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index 1edadfd7189302..1d6dfa95576434 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -243,7 +243,7 @@ const Formula &forceBoolValue(Environment &Env, const Expr &Expr) {
return Value->formula();
Value = &Env.makeAtomicBoolValue();
- Env.setValueStrict(Expr, *Value);
+ Env.setValue(Expr, *Value);
return Value->formula();
}
@@ -437,10 +437,10 @@ void transferUnwrapCall(const Expr *UnwrapExpr, const Expr *ObjectExpr,
LatticeTransferState &State) {
if (auto *OptionalVal =
getValueBehindPossiblePointer(*ObjectExpr, State.Env)) {
- if (State.Env.getStorageLocationStrict(*UnwrapExpr) == nullptr)
+ if (State.Env.getStorageLocation(*UnwrapExpr) == nullptr)
if (auto *Loc = maybeInitializeOptionalValueMember(
UnwrapExpr->getType(), *OptionalVal, State.Env))
- State.Env.setStorageLocationStrict(*UnwrapExpr, *Loc);
+ State.Env.setStorageLocation(*UnwrapExpr, *Loc);
}
}
@@ -450,8 +450,7 @@ void transferArrowOpCall(const Expr *UnwrapExpr, const Expr *ObjectExpr,
getValueBehindPossiblePointer(*ObjectExpr, State.Env)) {
if (auto *Loc = maybeInitializeOptionalValueMember(
UnwrapExpr->getType()->getPointeeType(), *OptionalVal, State.Env)) {
- State.Env.setValueStrict(*UnwrapExpr,
- State.Env.create<PointerValue>(*Loc));
+ State.Env.setValue(*UnwrapExpr, State.Env.create<PointerValue>(*Loc));
}
}
}
@@ -469,7 +468,7 @@ void transferOptionalHasValueCall(const CXXMemberCallExpr *CallExpr,
if (auto *HasValueVal = getHasValue(
State.Env, getValueBehindPossiblePointer(
*CallExpr->getImplicitObjectArgument(), State.Env))) {
- State.Env.setValueStrict(*CallExpr, *HasValueVal);
+ State.Env.setValue(*CallExpr, *HasValueVal);
}
}
@@ -538,11 +537,11 @@ void transferCallReturningOptional(const CallExpr *E,
Loc = &State.Env.getResultObjectLocation(*E);
} else {
Loc = cast_or_null<AggregateStorageLocation>(
- State.Env.getStorageLocationStrict(*E));
+ State.Env.getStorageLocation(*E));
if (Loc == nullptr) {
Loc =
&cast<AggregateStorageLocation>(State.Env.createStorageLocation(*E));
- State.Env.setStorageLocationStrict(*E, *Loc);
+ State.Env.setStorageLocation(*E, *Loc);
}
}
@@ -552,7 +551,7 @@ void transferCallReturningOptional(const CallExpr *E,
void constructOptionalValue(const Expr &E, Environment &Env,
BoolValue &HasValueVal) {
AggregateStorageLocation &Loc = Env.getResultObjectLocation(E);
- Env.setValueStrict(E, createOptionalValue(Loc, HasValueVal, Env));
+ Env.setValue(E, createOptionalValue(Loc, HasValueVal, Env));
}
/// Returns a symbolic value for the "has_value" property of an `optional<T>`
@@ -600,11 +599,11 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
assert(E->getNumArgs() > 0);
if (auto *Loc = cast<AggregateStorageLocation>(
- State.Env.getStorageLocationStrict(*E->getArg(0)))) {
+ State.Env.getStorageLocation(*E->getArg(0)))) {
createOptionalValue(*Loc, HasValueVal, State.Env);
// Assign a storage location for the whole expression.
- State.Env.setStorageLocationStrict(*E, *Loc);
+ State.Env.setStorageLocation(*E, *Loc);
}
}
@@ -663,7 +662,7 @@ void transferSwapCall(const CXXMemberCallExpr *E,
LatticeTransferState &State) {
assert(E->getNumArgs() == 1);
auto *OtherLoc = cast_or_null<AggregateStorageLocation>(
- State.Env.getStorageLocationStrict(*E->getArg(0)));
+ State.Env.getStorageLocation(*E->getArg(0)));
transferSwap(getImplicitObjectLocation(*E, State.Env), OtherLoc, State.Env);
}
@@ -671,9 +670,9 @@ void transferStdSwapCall(const CallExpr *E, const MatchFinder::MatchResult &,
LatticeTransferState &State) {
assert(E->getNumArgs() == 2);
auto *Arg0Loc = cast_or_null<AggregateStorageLocation>(
- State.Env.getStorageLocationStrict(*E->getArg(0)));
+ State.Env.getStorageLocation(*E->getArg(0)));
auto *Arg1Loc = cast_or_null<AggregateStorageLocation>(
- State.Env.getStorageLocationStrict(*E->getArg(1)));
+ State.Env.getStorageLocation(*E->getArg(1)));
transferSwap(Arg0Loc, Arg1Loc, State.Env);
}
@@ -681,8 +680,8 @@ void transferStdForwardCall(const CallExpr *E, const MatchFinder::MatchResult &,
LatticeTransferState &State) {
assert(E->getNumArgs() == 1);
- if (auto *Loc = State.Env.getStorageLocationStrict(*E->getArg(0)))
- State.Env.setStorageLocationStrict(*E, *Loc);
+ if (auto *Loc = State.Env.getStorageLocation(*E->getArg(0)))
+ State.Env.setStorageLocation(*E, *Loc);
}
const Formula &evaluateEquality(Arena &A, const Formula &EqVal,
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 66220553c66d47..dee3687d7da0ae 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -74,7 +74,7 @@ static BoolValue &unpackValue(BoolValue &V, Environment &Env) {
// value, if any unpacking occured. Also, does the lvalue-to-rvalue conversion,
// by skipping past the reference.
static Value *maybeUnpackLValueExpr(const Expr &E, Environment &Env) {
- auto *Loc = Env.getStorageLocationStrict(E);
+ auto *Loc = Env.getStorageLocation(E);
if (Loc == nullptr)
return nullptr;
auto *Val = Env.getValue(*Loc);
@@ -92,13 +92,13 @@ static Value *maybeUnpackLValueExpr(const Expr &E, Environment &Env) {
static void propagateValue(const Expr &From, const Expr &To, Environment &Env) {
if (auto *Val = Env.getValue(From))
- Env.setValueStrict(To, *Val);
+ Env.setValue(To, *Val);
}
static void propagateStorageLocation(const Expr &From, const Expr &To,
Environment &Env) {
- if (auto *Loc = Env.getStorageLocationStrict(From))
- Env.setStorageLocationStrict(To, *Loc);
+ if (auto *Loc = Env.getStorageLocation(From))
+ Env.setStorageLocation(To, *Loc);
}
// Propagates the value or storage location of `From` to `To` in cases where
@@ -129,7 +129,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
switch (S->getOpcode()) {
case BO_Assign: {
- auto *LHSLoc = Env.getStorageLocationStrict(*LHS);
+ auto *LHSLoc = Env.getStorageLocation(*LHS);
if (LHSLoc == nullptr)
break;
@@ -141,7 +141,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
Env.setValue(*LHSLoc, *RHSVal);
// Assign a storage location for the whole expression.
- Env.setStorageLocationStrict(*S, *LHSLoc);
+ Env.setStorageLocation(*S, *LHSLoc);
break;
}
case BO_LAnd:
@@ -150,17 +150,16 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
BoolValue &RHSVal = getLogicOperatorSubExprValue(*RHS);
if (S->getOpcode() == BO_LAnd)
- Env.setValueStrict(*S, Env.makeAnd(LHSVal, RHSVal));
+ Env.setValue(*S, Env.makeAnd(LHSVal, RHSVal));
else
- Env.setValueStrict(*S, Env.makeOr(LHSVal, RHSVal));
+ Env.setValue(*S, Env.makeOr(LHSVal, RHSVal));
break;
}
case BO_NE:
case BO_EQ: {
auto &LHSEqRHSValue = evaluateBooleanEquality(*LHS, *RHS, Env);
- Env.setValueStrict(*S, S->getOpcode() == BO_EQ
- ? LHSEqRHSValue
- : Env.makeNot(LHSEqRHSValue));
+ Env.setValue(*S, S->getOpcode() == BO_EQ ? LHSEqRHSValue
+ : Env.makeNot(LHSEqRHSValue));
break;
}
case BO_Comma: {
@@ -188,7 +187,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (DeclLoc == nullptr)
return;
- Env.setStorageLocationStrict(*S, *DeclLoc);
+ Env.setStorageLocation(*S, *DeclLoc);
}
void VisitDeclStmt(const DeclStmt *S) {
@@ -234,7 +233,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
VisitDeclRefExpr(DE);
VisitMemberExpr(ME);
- if (auto *Loc = Env.getStorageLocationStrict(*ME))
+ if (auto *Loc = Env.getStorageLocation(*ME))
Env.setStorageLocation(*B, *Loc);
} else if (auto *VD = B->getHoldingVar()) {
// Holding vars are used to back the `BindingDecl`s of tuple-like
@@ -263,11 +262,11 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
// boolean.
if (auto *SubExprVal =
dyn_cast_or_null<BoolValue>(Env.getValue(*SubExpr)))
- Env.setValueStrict(*S, *SubExprVal);
+ Env.setValue(*S, *SubExprVal);
else
// FIXME: If integer modeling is added, then update this code to create
// the boolean based on the integer model.
- Env.setValueStrict(*S, Env.makeAtomicBoolValue());
+ Env.setValue(*S, Env.makeAtomicBoolValue());
break;
}
@@ -279,7 +278,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (SubExprVal == nullptr)
break;
- Env.setValueStrict(*S, *SubExprVal);
+ Env.setValue(*S, *SubExprVal);
break;
}
@@ -304,7 +303,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
case CK_NullToPointer: {
auto &NullPointerVal =
Env.getOrCreateNullPointerValue(S->getType()->getPointeeType());
- Env.setValueStrict(*S, NullPointerVal);
+ Env.setValue(*S, NullPointerVal);
break;
}
case CK_NullToMemberPointer:
@@ -312,11 +311,11 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
// with this expression.
break;
case CK_FunctionToPointerDecay: {
- StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
+ StorageLocation *PointeeLoc = Env.getStorageLocation(*SubExpr);
if (PointeeLoc == nullptr)
break;
- Env.setValueStrict(*S, Env.create<PointerValue>(*PointeeLoc));
+ Env.setValue(*S, Env.create<PointerValue>(*PointeeLoc));
break;
}
case CK_BuiltinFnToFnPtr:
@@ -341,7 +340,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (SubExprVal == nullptr)
break;
- Env.setStorageLocationStrict(*S, SubExprVal->getPointeeLoc());
+ Env.setStorageLocation(*S, SubExprVal->getPointeeLoc());
break;
}
case UO_AddrOf: {
@@ -349,8 +348,8 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (S->getType()->isMemberPointerType())
break;
- if (StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr))
- Env.setValueStrict(*S, Env.create<PointerValue>(*PointeeLoc));
+ if (StorageLocation *PointeeLoc = Env.getStorageLocation(*SubExpr))
+ Env.setValue(*S, Env.create<PointerValue>(*PointeeLoc));
break;
}
case UO_LNot: {
@@ -358,7 +357,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (SubExprVal == nullptr)
break;
- Env.setValueStrict(*S, Env.makeNot(*SubExprVal));
+ Env.setValue(*S, Env.makeNot(*SubExprVal));
break;
}
default:
@@ -373,12 +372,12 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
// `this` expression's pointee.
return;
- Env.setValueStrict(*S, Env.create<PointerValue>(*ThisPointeeLoc));
+ Env.setValue(*S, Env.create<PointerValue>(*ThisPointeeLoc));
}
void VisitCXXNewExpr(const CXXNewExpr *S) {
if (Value *Val = Env.createValue(S->getType()))
- Env.setValueStrict(*S, *Val);
+ Env.setValue(*S, *Val);
}
void VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
@@ -404,7 +403,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
// FIXME: Model NRVO.
Env.setReturnValue(Val);
} else {
- auto *Loc = Env.getStorageLocationStrict(*Ret);
+ auto *Loc = Env.getStorageLocation(*Ret);
if (Loc == nullptr)
return;
@@ -431,7 +430,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (VarDeclLoc == nullptr)
return;
- Env.setStorageLocationStrict(*S, *VarDeclLoc);
+ Env.setStorageLocation(*S, *VarDeclLoc);
return;
}
}
@@ -443,7 +442,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
auto *MemberLoc = BaseLoc->getChild(*Member);
if (MemberLoc == nullptr)
return;
- Env.setStorageLocationStrict(*S, *MemberLoc);
+ Env.setStorageLocation(*S, *MemberLoc);
}
void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
@@ -464,17 +463,17 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
const Expr *Arg = S->getArg(0);
assert(Arg != nullptr);
- auto *ArgLoc = cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(*Arg));
+ auto *ArgLoc =
+ cast_or_null<AggregateStorageLocation>(Env.getStorageLocation(*Arg));
if (ArgLoc == nullptr)
return;
if (S->isElidable()) {
if (Value *Val = Env.getValue(*ArgLoc))
- Env.setValueStrict(*S, *Val);
+ Env.setValue(*S, *Val);
} else {
auto &Val = *cast<StructValue>(Env.createValue(S->getType()));
- Env.setValueStrict(*S, Val);
+ Env.setValue(*S, Val);
copyRecord(*ArgLoc, Val.getAggregateLoc(), Env);
}
return;
@@ -511,14 +510,14 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
!Method->isMoveAssignmentOperator())
return;
- auto *LocSrc = cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(*Arg1));
- auto *LocDst = cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocationStrict(*Arg0));
+ auto *LocSrc =
+ cast_or_null<AggregateStorageLocation>(Env.getStorageLocation(*Arg1));
+ auto *LocDst =
+ cast_or_null<AggregateStorageLocation>(Env.getStorageLocation(*Arg0));
if (LocSrc != nullptr && LocDst != nullptr) {
copyRecord(*LocSrc, *LocDst, Env);
- Env.setStorageLocationStrict(*S, *LocDst);
+ Env.setStorageLocation(*S, *LocDst);
}
}
}
@@ -534,7 +533,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
void VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
if (Value *Val = Env.createValue(S->getType()))
- Env.setValueStrict(*S, *Val);
+ Env.setValue(*S, *Val);
}
void VisitCallExpr(const CallExpr *S) {
@@ -547,11 +546,11 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
const Expr *Arg = S->getArg(0);
assert(Arg != nullptr);
- auto *ArgLoc = Env.getStorageLocationStrict(*Arg);
+ auto *ArgLoc = Env.getStorageLocation(*Arg);
if (ArgLoc == nullptr)
return;
- Env.setStorageLocationStrict(*S, *ArgLoc);
+ Env.setStorageLocation(*S, *ArgLoc);
} else if (S->getDirectCallee() != nullptr &&
S->getDirectCallee()->getBuiltinID() ==
Builtin::BI__builtin_expect) {
@@ -560,7 +559,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
auto *ArgVal = Env.getValue(*S->getArg(0));
if (ArgVal == nullptr)
return;
- Env.setValueStrict(*S, *ArgVal);
+ Env.setValue(*S, *ArgVal);
} else if (const FunctionDecl *F = S->getDirectCallee()) {
transferInlineCall(S, F);
}
@@ -575,13 +574,13 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
return;
if (StructValue *StructVal = dyn_cast<StructValue>(SubExprVal)) {
- Env.setStorageLocationStrict(*S, StructVal->getAggregateLoc());
+ Env.setStorageLocation(*S, StructVal->getAggregateLoc());
return;
}
StorageLocation &Loc = Env.createStorageLocation(*S);
Env.setValue(Loc, *SubExprVal);
- Env.setStorageLocationStrict(*S, Loc);
+ Env.setStorageLocation(*S, Loc);
}
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
@@ -605,9 +604,9 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
// `a = b ? c : d` we can add `b => a == c && !b => a == d` to the flow
// condition.
if (S->isGLValue())
- Env.setStorageLocationStrict(*S, Env.createObject(S->getType()));
+ Env.setStorageLocation(*S, Env.createObject(S->getType()));
else if (Value *Val = Env.createValue(S->getType()))
- Env.setValueStrict(*S, *Val);
+ Env.setValue(*S, *Val);
}
void VisitInitListExpr(const InitListExpr *S) {
@@ -615,7 +614,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (!Type->isStructureOrClassType()) {
if (auto *Val = Env.createValue(Type))
- Env.setValueStrict(*S, *Val);
+ Env.setValue(*S, *Val);
return;
}
@@ -646,17 +645,17 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
Env.setValue(Loc, StructVal);
- Env.setValueStrict(*S, StructVal);
+ Env.setValue(*S, StructVal);
// FIXME: Implement array initialization.
}
void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
- Env.setValueStrict(*S, Env.getBoolLiteralValue(S->getValue()));
+ Env.setValue(*S, Env.getBoolLiteralValue(S->getValue()));
}
void VisitIntegerLiteral(const IntegerLiteral *S) {
- Env.setValueStrict(*S, Env.getIntLiteralValue(S->getValue()));
+ Env.setValue(*S, Env.getIntLiteralValue(S->getValue()));
}
void VisitParenExpr(const ParenExpr *S) {
diff --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index bd2074374e1fbc..586c72baaf5fb9 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -135,7 +135,7 @@ class TerminatorVisitor
// for the condition expression, even if just an atom.
if (Val == nullptr) {
Val = &Env.makeAtomicBoolValue();
- Env.setValueStrict(Cond, *Val);
+ Env.setValue(Cond, *Val);
}
bool ConditionValue = true;
@@ -402,7 +402,7 @@ builtinTransferInitializer(const CFGInitializer &Elt,
// the `AggregateStorageLocation` already exists. We should explore if there's
// anything that we can do to change this.
if (Member->getType()->isReferenceType()) {
- auto *InitExprLoc = Env.getStorageLocationStrict(*InitExpr);
+ auto *InitExprLoc = Env.getStorageLocation(*InitExpr);
if (InitExprLoc == nullptr)
return;
diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
index ba316f7d35e895..cba9867912c963 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -279,9 +279,9 @@ TEST_F(EnvironmentTest, RefreshStructValue) {
ASSERT_THAT(DRE, NotNull());
Environment Env(DAContext, *Target);
- EXPECT_THAT(Env.getStorageLocationStrict(*DRE), IsNull());
+ EXPECT_THAT(Env.getStorageLocation(*DRE), IsNull());
refreshStructValue(*DRE, Env);
- EXPECT_THAT(Env.getStorageLocationStrict(*DRE), NotNull());
+ EXPECT_THAT(Env.getStorageLocation(*DRE), NotNull());
}
} // namespace
diff --git a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
index ef83dddcfa57ed..f8897929a59cf4 100644
--- a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -117,7 +117,7 @@ getValueAndSignProperties(const UnaryOperator *UO,
auto *UnaryOpValue = State.Env.getValue(*UO);
if (!UnaryOpValue) {
UnaryOpValue = &State.Env.makeAtomicBoolValue();
- State.Env.setValueStrict(*UO, *UnaryOpValue);
+ State.Env.setValue(*UO, *UnaryOpValue);
}
// Properties for the operand (sub expression).
@@ -137,7 +137,7 @@ void transferBinary(const BinaryOperator *BO, const MatchFinder::MatchResult &M,
Comp = &V->formula();
} else {
Comp = &A.makeAtomRef(A.makeAtom());
- State.Env.setValueStrict(*BO, A.makeBoolValue(*Comp));
+ State.Env.setValue(*BO, A.makeBoolValue(*Comp));
}
// FIXME Use this as well:
@@ -260,10 +260,10 @@ void transferUnaryNot(const UnaryOperator *UO,
Value *getOrCreateValue(const Expr *E, Environment &Env) {
Value *Val = nullptr;
if (E->isGLValue()) {
- StorageLocation *Loc = Env.getStorageLocationStrict(*E);
+ StorageLocation *Loc = Env.getStorageLocation(*E);
if (!Loc) {
Loc = &Env.createStorageLocation(*E);
- Env.setStorageLocationStrict(*E, *Loc);
+ Env.setStorageLocation(*E, *Loc);
}
Val = Env.getValue(*Loc);
if (!Val) {
@@ -274,7 +274,7 @@ Value *getOrCreateValue(const Expr *E, Environment &Env) {
Val = Env.getValue(*E);
if (!Val) {
Val = Env.createValue(E->getType());
- Env.setValueStrict(*E, *Val);
+ Env.setValue(*E, *Val);
}
}
assert(Val != nullptr);
diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 83faed42bad030..3e73a40ee2a454 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -1243,7 +1243,7 @@ class TopAnalysis final : public DataflowAnalysis<TopAnalysis, NoopLattice> {
match(callExpr(callee(functionDecl(hasName("makeTop")))).bind("top"),
*S, getASTContext());
if (const auto *E = selectFirst<CallExpr>("top", Matches)) {
- Env.setValueStrict(*E, Env.makeTopBoolValue());
+ Env.setValue(*E, Env.makeTopBoolValue());
}
}
More information about the cfe-commits
mailing list