[clang] 9940fac - [clang][dataflow][NFC] Remove `SkipPast` parameter from `getStorageLocation(const ValueDecl &).
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Mon May 8 00:10:53 PDT 2023
Author: Martin Braenne
Date: 2023-05-08T07:10:44Z
New Revision: 9940fac7539597c08f03381527011e1280cd7489
URL: https://github.com/llvm/llvm-project/commit/9940fac7539597c08f03381527011e1280cd7489
DIFF: https://github.com/llvm/llvm-project/commit/9940fac7539597c08f03381527011e1280cd7489.diff
LOG: [clang][dataflow][NFC] Remove `SkipPast` parameter from `getStorageLocation(const ValueDecl &).
This parameter was already a no-op, so removing it doesn't change behavior.
Depends On D149144
Reviewed By: ymandel, xazax.hun, gribozavr2
Differential Revision: https://reviews.llvm.org/D149151
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.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 cd1703be0507b..58b1d8b172b3d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -281,12 +281,7 @@ class Environment {
///
/// Note that if `D` has reference type, the storage location that is returned
/// refers directly to the referenced object, not a `ReferenceValue`.
- ///
- /// The `SP` parameter is deprecated and has no effect. In addition, it is
- /// not permitted to pass `SkipPast::ReferenceThenPointer` for this parameter.
- /// New uses of this function should use the default argument for `SP`.
- StorageLocation *getStorageLocation(const ValueDecl &D,
- SkipPast SP = SkipPast::None) const;
+ StorageLocation *getStorageLocation(const ValueDecl &D) const;
/// Assigns `Loc` as the storage location of `E` in the environment.
///
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index a4d3768b8b189..479aa12d191ee 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -245,7 +245,7 @@ void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) {
DACtx->addModeledFields(Fields);
for (const VarDecl *D : Vars) {
- if (getStorageLocation(*D, SkipPast::None) != nullptr)
+ if (getStorageLocation(*D) != nullptr)
continue;
auto &Loc = createStorageLocation(D->getType().getNonReferenceType());
setStorageLocation(*D, Loc);
@@ -254,7 +254,7 @@ void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) {
}
for (const FunctionDecl *FD : Funcs) {
- if (getStorageLocation(*FD, SkipPast::None) != nullptr)
+ if (getStorageLocation(*FD) != nullptr)
continue;
auto &Loc = createStorageLocation(FD->getType());
setStorageLocation(*FD, Loc);
@@ -605,10 +605,7 @@ void Environment::setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
DeclToLoc[&D] = &Loc;
}
-StorageLocation *Environment::getStorageLocation(const ValueDecl &D,
- SkipPast SP) const {
- assert(SP != SkipPast::ReferenceThenPointer);
-
+StorageLocation *Environment::getStorageLocation(const ValueDecl &D) const {
auto It = DeclToLoc.find(&D);
if (It == DeclToLoc.end())
return nullptr;
@@ -686,7 +683,7 @@ Value *Environment::getValue(const StorageLocation &Loc) const {
Value *Environment::getValue(const ValueDecl &D, SkipPast SP) const {
assert(SP != SkipPast::ReferenceThenPointer);
- auto *Loc = getStorageLocation(D, SP);
+ auto *Loc = getStorageLocation(D);
if (Loc == nullptr)
return nullptr;
return getValue(*Loc);
diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index ddabf352fd111..50eb7e9011bda 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -219,7 +219,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
void VisitDeclRefExpr(const DeclRefExpr *S) {
const ValueDecl *VD = S->getDecl();
assert(VD != nullptr);
- auto *DeclLoc = Env.getStorageLocation(*VD, SkipPast::None);
+ auto *DeclLoc = Env.getStorageLocation(*VD);
if (DeclLoc == nullptr)
return;
@@ -533,7 +533,7 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
if (auto *D = dyn_cast<VarDecl>(Member)) {
if (D->hasGlobalStorage()) {
- auto *VarDeclLoc = Env.getStorageLocation(*D, SkipPast::None);
+ auto *VarDeclLoc = Env.getStorageLocation(*D);
if (VarDeclLoc == nullptr)
return;
diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
index 770c7a50195e9..2f874b44c49bf 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -218,8 +218,8 @@ TEST_F(EnvironmentTest, InitGlobalVarsFieldFun) {
// Verify the global variable is populated when we analyze `Target`.
Environment Env(DAContext, *Fun);
- const auto *GlobalLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*GlobalDecl, SkipPast::None));
+ const auto *GlobalLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*GlobalDecl));
const auto *GlobalVal = cast<StructValue>(Env.getValue(*GlobalLoc));
const auto *BarVal = GlobalVal->getChild(*BarDecl);
ASSERT_THAT(BarVal, NotNull());
diff --git a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
index 405d5b217c0be..9a5a7fd0b5532 100644
--- a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -88,8 +88,7 @@ void transferUninitializedInt(const DeclStmt *D,
LatticeTransferState &State) {
const auto *Var = M.Nodes.getNodeAs<clang::VarDecl>(kVar);
assert(Var != nullptr);
- const StorageLocation *Loc =
- State.Env.getStorageLocation(*Var, SkipPast::None);
+ const StorageLocation *Loc = State.Env.getStorageLocation(*Var);
Value *Val = State.Env.getValue(*Loc);
initUnknown(*Val, State.Env);
}
@@ -427,7 +426,7 @@ getProperty(const Environment &Env, ASTContext &ASTCtx, const Node *N,
StringRef Property) {
if (!N)
return {testing::AssertionFailure() << "No node", nullptr};
- const StorageLocation *Loc = Env.getStorageLocation(*N, SkipPast::None);
+ const StorageLocation *Loc = Env.getStorageLocation(*N);
if (!isa_and_nonnull<ScalarStorageLocation>(Loc))
return {testing::AssertionFailure() << "No location", nullptr};
const Value *Val = Env.getValue(*Loc);
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 0283fe74e7790..d2e86c5211975 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -99,7 +99,7 @@ TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- EXPECT_EQ(Env.getStorageLocation(*FooDecl, SkipPast::None), nullptr);
+ EXPECT_EQ(Env.getStorageLocation(*FooDecl), nullptr);
},
LangStandard::lang_cxx17,
/*ApplyBuiltinTransfer=*/false);
@@ -122,8 +122,7 @@ TEST(TransferTest, BoolVarDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -148,8 +147,7 @@ TEST(TransferTest, IntVarDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -228,8 +226,8 @@ TEST(TransferTest, StructFieldUnmodeled) {
}
ASSERT_THAT(UnmodeledDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *UnmodeledLoc = &FooLoc->getChild(*UnmodeledDecl);
ASSERT_TRUE(isa<ScalarStorageLocation>(UnmodeledLoc));
ASSERT_THAT(Env.getValue(*UnmodeledLoc), IsNull());
@@ -275,8 +273,8 @@ TEST(TransferTest, StructVarDecl) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -323,8 +321,8 @@ TEST(TransferTest, StructVarDeclWithInit) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -370,8 +368,8 @@ TEST(TransferTest, ClassVarDecl) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -402,8 +400,7 @@ TEST(TransferTest, ReferenceVarDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<AggregateStorageLocation>(FooLoc));
const Value *FooReferentVal = Env.getValue(*FooLoc);
@@ -490,8 +487,8 @@ TEST(TransferTest, SelfReferentialReferenceVarDecl) {
ASSERT_THAT(BazRefDecl, NotNull());
ASSERT_THAT(BazPtrDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *FooReferentVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal =
@@ -546,8 +543,7 @@ TEST(TransferTest, PointerVarDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const PointerValue *FooVal = cast<PointerValue>(Env.getValue(*FooLoc));
@@ -651,8 +647,8 @@ TEST(TransferTest, SelfReferentialPointerVarDecl) {
ASSERT_THAT(BazRefDecl, NotNull());
ASSERT_THAT(BazPtrDecl, NotNull());
- const auto *FooLoc = cast<ScalarStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<ScalarStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *FooVal = cast<PointerValue>(Env.getValue(*FooLoc));
const auto *FooPointeeVal =
cast<StructValue>(Env.getValue(FooVal->getPointeeLoc()));
@@ -705,12 +701,10 @@ TEST(TransferTest, MultipleVarsDecl) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
- const StorageLocation *BarLoc =
- Env.getStorageLocation(*BarDecl, SkipPast::None);
+ const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(BarLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -753,26 +747,25 @@ TEST(TransferTest, JoinVarDecl) {
const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1");
- const StorageLocation *FooLoc =
- Env1.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env1.getStorageLocation(*FooDecl);
EXPECT_THAT(FooLoc, NotNull());
- EXPECT_THAT(Env1.getStorageLocation(*BarDecl, SkipPast::None), IsNull());
- EXPECT_THAT(Env1.getStorageLocation(*BazDecl, SkipPast::None), IsNull());
+ EXPECT_THAT(Env1.getStorageLocation(*BarDecl), IsNull());
+ EXPECT_THAT(Env1.getStorageLocation(*BazDecl), IsNull());
const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2");
- EXPECT_EQ(Env2.getStorageLocation(*FooDecl, SkipPast::None), FooLoc);
- EXPECT_THAT(Env2.getStorageLocation(*BarDecl, SkipPast::None), NotNull());
- EXPECT_THAT(Env2.getStorageLocation(*BazDecl, SkipPast::None), IsNull());
+ EXPECT_EQ(Env2.getStorageLocation(*FooDecl), FooLoc);
+ EXPECT_THAT(Env2.getStorageLocation(*BarDecl), NotNull());
+ EXPECT_THAT(Env2.getStorageLocation(*BazDecl), IsNull());
const Environment &Env3 = getEnvironmentAtAnnotation(Results, "p3");
- EXPECT_EQ(Env3.getStorageLocation(*FooDecl, SkipPast::None), FooLoc);
- EXPECT_THAT(Env3.getStorageLocation(*BarDecl, SkipPast::None), IsNull());
- EXPECT_THAT(Env3.getStorageLocation(*BazDecl, SkipPast::None), NotNull());
+ EXPECT_EQ(Env3.getStorageLocation(*FooDecl), FooLoc);
+ EXPECT_THAT(Env3.getStorageLocation(*BarDecl), IsNull());
+ EXPECT_THAT(Env3.getStorageLocation(*BazDecl), NotNull());
const Environment &Env4 = getEnvironmentAtAnnotation(Results, "p4");
- EXPECT_EQ(Env4.getStorageLocation(*FooDecl, SkipPast::None), FooLoc);
- EXPECT_THAT(Env4.getStorageLocation(*BarDecl, SkipPast::None), IsNull());
- EXPECT_THAT(Env4.getStorageLocation(*BazDecl, SkipPast::None), IsNull());
+ EXPECT_EQ(Env4.getStorageLocation(*FooDecl), FooLoc);
+ EXPECT_THAT(Env4.getStorageLocation(*BarDecl), IsNull());
+ EXPECT_THAT(Env4.getStorageLocation(*BazDecl), IsNull());
});
}
@@ -971,8 +964,7 @@ TEST(TransferTest, MultipleParamDecls) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -981,8 +973,7 @@ TEST(TransferTest, MultipleParamDecls) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const StorageLocation *BarLoc =
- Env.getStorageLocation(*BarDecl, SkipPast::None);
+ const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(BarLoc));
const Value *BarVal = Env.getValue(*BarLoc);
@@ -1024,8 +1015,8 @@ TEST(TransferTest, StructParamDecl) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -1054,8 +1045,7 @@ TEST(TransferTest, ReferenceParamDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<AggregateStorageLocation>(FooLoc));
const Value *FooReferentVal = Env.getValue(*FooLoc);
@@ -1082,8 +1072,7 @@ TEST(TransferTest, PointerParamDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const PointerValue *FooVal = cast<PointerValue>(Env.getValue(*FooLoc));
@@ -1129,8 +1118,8 @@ TEST(TransferTest, StructMember) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<IntegerValue>(FooVal->getChild(*BarDecl));
@@ -1260,8 +1249,8 @@ TEST(TransferTest, DerivedBaseMemberClass) {
ASSERT_THAT(APrivateDecl, NotNull());
ASSERT_THAT(APublicDecl, NotNull());
- const auto &FooLoc = *cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto &FooLoc =
+ *cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto &FooVal = *cast<StructValue>(Env.getValue(FooLoc));
// Note: we can't test presence of children in `FooLoc`, because
@@ -1319,8 +1308,8 @@ static void derivedBaseMemberExpectations(
}
ASSERT_THAT(BarDecl, NotNull());
- const auto &FooLoc = *cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto &FooLoc =
+ *cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto &FooVal = *cast<StructValue>(Env.getValue(FooLoc));
EXPECT_THAT(FooVal.getChild(*BarDecl), NotNull());
EXPECT_EQ(Env.getValue(FooLoc.getChild(*BarDecl)), FooVal.getChild(*BarDecl));
@@ -1399,8 +1388,8 @@ TEST(TransferTest, ClassMember) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<IntegerValue>(FooVal->getChild(*BarDecl));
@@ -1489,8 +1478,8 @@ TEST(TransferTest, ReferenceMember) {
}
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<ReferenceValue>(FooVal->getChild(*BarDecl));
const auto *BarReferentVal =
@@ -1931,8 +1920,8 @@ TEST(TransferTest, TemporaryObject) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -1969,8 +1958,8 @@ TEST(TransferTest, ElidableConstructor) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarLoc =
cast<ScalarStorageLocation>(&FooLoc->getChild(*BarDecl));
@@ -2013,10 +2002,10 @@ TEST(TransferTest, AssignmentOperator) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const auto *FooLoc1 = cast<AggregateStorageLocation>(
- Env1.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc1 = cast<AggregateStorageLocation>(
- Env1.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc1 =
+ cast<AggregateStorageLocation>(Env1.getStorageLocation(*FooDecl));
+ const auto *BarLoc1 =
+ cast<AggregateStorageLocation>(Env1.getStorageLocation(*BarDecl));
const auto *FooVal1 = cast<StructValue>(Env1.getValue(*FooLoc1));
const auto *BarVal1 = cast<StructValue>(Env1.getValue(*BarLoc1));
@@ -2028,10 +2017,10 @@ TEST(TransferTest, AssignmentOperator) {
cast<IntegerValue>(Env1.getValue(BarLoc1->getChild(*BazDecl)));
EXPECT_NE(FooBazVal1, BarBazVal1);
- const auto *FooLoc2 = cast<AggregateStorageLocation>(
- Env2.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc2 = cast<AggregateStorageLocation>(
- Env2.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc2 =
+ cast<AggregateStorageLocation>(Env2.getStorageLocation(*FooDecl));
+ const auto *BarLoc2 =
+ cast<AggregateStorageLocation>(Env2.getStorageLocation(*BarDecl));
const auto *FooVal2 = cast<StructValue>(Env2.getValue(*FooLoc2));
const auto *BarVal2 = cast<StructValue>(Env2.getValue(*BarLoc2));
@@ -2074,10 +2063,10 @@ TEST(TransferTest, CopyConstructor) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
+ const auto *BarLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*BarDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<StructValue>(Env.getValue(*BarLoc));
@@ -2122,10 +2111,10 @@ TEST(TransferTest, CopyConstructorWithDefaultArgument) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
+ const auto *BarLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*BarDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<StructValue>(Env.getValue(*BarLoc));
@@ -2168,10 +2157,10 @@ TEST(TransferTest, CopyConstructorWithParens) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const auto *FooLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc = cast<AggregateStorageLocation>(
- Env.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
+ const auto *BarLoc =
+ cast<AggregateStorageLocation>(Env.getStorageLocation(*BarDecl));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<StructValue>(Env.getValue(*BarLoc));
@@ -2231,10 +2220,10 @@ TEST(TransferTest, MoveConstructor) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const auto *FooLoc1 = cast<AggregateStorageLocation>(
- Env1.getStorageLocation(*FooDecl, SkipPast::None));
- const auto *BarLoc1 = cast<AggregateStorageLocation>(
- Env1.getStorageLocation(*BarDecl, SkipPast::None));
+ const auto *FooLoc1 =
+ cast<AggregateStorageLocation>(Env1.getStorageLocation(*FooDecl));
+ const auto *BarLoc1 =
+ cast<AggregateStorageLocation>(Env1.getStorageLocation(*BarDecl));
const auto *FooVal1 = cast<StructValue>(Env1.getValue(*FooLoc1));
const auto *BarVal1 = cast<StructValue>(Env1.getValue(*BarLoc1));
@@ -2246,8 +2235,8 @@ TEST(TransferTest, MoveConstructor) {
cast<IntegerValue>(Env1.getValue(BarLoc1->getChild(*BazDecl)));
EXPECT_NE(FooBazVal1, BarBazVal1);
- const auto *FooLoc2 = cast<AggregateStorageLocation>(
- Env2.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc2 =
+ cast<AggregateStorageLocation>(Env2.getStorageLocation(*FooDecl));
const auto *FooVal2 = cast<StructValue>(Env2.getValue(*FooLoc2));
EXPECT_EQ(FooVal2, BarVal1);
@@ -2523,8 +2512,8 @@ TEST(TransferTest, AddrOfValue) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<ScalarStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<ScalarStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarVal =
cast<PointerValue>(Env.getValue(*BarDecl, SkipPast::None));
EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc);
@@ -2806,7 +2795,7 @@ TEST(TransferTest, AssignToUnionMember) {
ASSERT_THAT(FooDecl, NotNull());
const auto *BazLoc = dyn_cast_or_null<AggregateStorageLocation>(
- Env.getStorageLocation(*BazDecl, SkipPast::None));
+ Env.getStorageLocation(*BazDecl));
ASSERT_THAT(BazLoc, NotNull());
ASSERT_THAT(Env.getValue(*BazLoc), NotNull());
@@ -2817,7 +2806,7 @@ TEST(TransferTest, AssignToUnionMember) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const auto *BarLoc = Env.getStorageLocation(*BarDecl, SkipPast::None);
+ const auto *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(BarLoc));
EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazVal);
@@ -3221,8 +3210,7 @@ TEST(TransferTest, StaticIntSingleVarDecl) {
const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -3251,12 +3239,10 @@ TEST(TransferTest, StaticIntGroupVarDecl) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
+ const StorageLocation *FooLoc = Env.getStorageLocation(*FooDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
- const StorageLocation *BarLoc =
- Env.getStorageLocation(*BarDecl, SkipPast::None);
+ const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(BarLoc));
const Value *FooVal = Env.getValue(*FooLoc);
@@ -3671,7 +3657,7 @@ TEST(TransferTest, LoopWithStructReferenceAssignmentConverges) {
ASSERT_THAT(LVal, NotNull());
EXPECT_EQ(&LVal->getPointeeLoc(),
- InnerEnv.getStorageLocation(*ValDecl, SkipPast::Reference));
+ InnerEnv.getStorageLocation(*ValDecl));
// Outer.
LVal =
@@ -3681,7 +3667,7 @@ TEST(TransferTest, LoopWithStructReferenceAssignmentConverges) {
// The loop body may not have been executed, so we should not conclude
// that `l` points to `val`.
EXPECT_NE(&LVal->getPointeeLoc(),
- OuterEnv.getStorageLocation(*ValDecl, SkipPast::Reference));
+ OuterEnv.getStorageLocation(*ValDecl));
});
}
@@ -3746,23 +3732,21 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToRefs) {
const ValueDecl *BoundBarRefDecl = findValueDecl(ASTCtx, "BoundBarRef");
ASSERT_THAT(BoundBarRefDecl, NotNull());
- const StorageLocation *FooRefLoc =
- Env.getStorageLocation(*FooRefDecl, SkipPast::Reference);
+ const StorageLocation *FooRefLoc = Env.getStorageLocation(*FooRefDecl);
ASSERT_THAT(FooRefLoc, NotNull());
- const StorageLocation *BarRefLoc =
- Env.getStorageLocation(*BarRefDecl, SkipPast::Reference);
+ const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl);
ASSERT_THAT(BarRefLoc, NotNull());
const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None);
ASSERT_THAT(QuxVal, NotNull());
const StorageLocation *BoundFooRefLoc =
- Env.getStorageLocation(*BoundFooRefDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundFooRefDecl);
EXPECT_EQ(BoundFooRefLoc, FooRefLoc);
const StorageLocation *BoundBarRefLoc =
- Env.getStorageLocation(*BoundBarRefDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundBarRefDecl);
EXPECT_EQ(BoundBarRefLoc, BarRefLoc);
EXPECT_EQ(Env.getValue(*BoundFooRefDecl, SkipPast::Reference), QuxVal);
@@ -3807,23 +3791,21 @@ TEST(TransferTest, StructuredBindingAssignFromStructRefMembersToRefs) {
const ValueDecl *BoundBarRefDecl = findValueDecl(ASTCtx, "BoundBarRef");
ASSERT_THAT(BoundBarRefDecl, NotNull());
- const StorageLocation *FooRefLoc =
- Env.getStorageLocation(*FooRefDecl, SkipPast::Reference);
+ const StorageLocation *FooRefLoc = Env.getStorageLocation(*FooRefDecl);
ASSERT_THAT(FooRefLoc, NotNull());
- const StorageLocation *BarRefLoc =
- Env.getStorageLocation(*BarRefDecl, SkipPast::Reference);
+ const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl);
ASSERT_THAT(BarRefLoc, NotNull());
const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None);
ASSERT_THAT(QuxVal, NotNull());
const StorageLocation *BoundFooRefLoc =
- Env.getStorageLocation(*BoundFooRefDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundFooRefDecl);
EXPECT_EQ(BoundFooRefLoc, FooRefLoc);
const StorageLocation *BoundBarRefLoc =
- Env.getStorageLocation(*BoundBarRefDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundBarRefDecl);
EXPECT_EQ(BoundBarRefLoc, BarRefLoc);
EXPECT_EQ(Env.getValue(*BoundFooRefDecl, SkipPast::Reference), QuxVal);
@@ -3869,23 +3851,21 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToInts) {
const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux");
ASSERT_THAT(QuxDecl, NotNull());
- const StorageLocation *FooRefLoc =
- Env.getStorageLocation(*FooRefDecl, SkipPast::Reference);
+ const StorageLocation *FooRefLoc = Env.getStorageLocation(*FooRefDecl);
ASSERT_THAT(FooRefLoc, NotNull());
- const StorageLocation *BarRefLoc =
- Env.getStorageLocation(*BarRefDecl, SkipPast::Reference);
+ const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl);
ASSERT_THAT(BarRefLoc, NotNull());
const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None);
ASSERT_THAT(QuxVal, NotNull());
const StorageLocation *BoundFooLoc =
- Env.getStorageLocation(*BoundFooDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundFooDecl);
EXPECT_NE(BoundFooLoc, FooRefLoc);
const StorageLocation *BoundBarLoc =
- Env.getStorageLocation(*BoundBarDecl, SkipPast::Reference);
+ Env.getStorageLocation(*BoundBarDecl);
EXPECT_NE(BoundBarLoc, BarRefLoc);
EXPECT_EQ(Env.getValue(*BoundFooDecl, SkipPast::Reference), QuxVal);
@@ -4079,12 +4059,10 @@ TEST(TransferTest, BinaryOperatorComma) {
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- const StorageLocation *BarLoc =
- Env.getStorageLocation(*BarDecl, SkipPast::Reference);
+ const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_THAT(BarLoc, NotNull());
- const StorageLocation *BazLoc =
- Env.getStorageLocation(*BazDecl, SkipPast::Reference);
+ const StorageLocation *BazLoc = Env.getStorageLocation(*BazDecl);
EXPECT_EQ(BazLoc, BarLoc);
});
}
diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 89f53ccdbfa2f..57ab1c652d602 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -723,8 +723,8 @@ TEST_F(WideningTest, DistinctPointersToTheSameLocationAreEquivalent) {
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
- const auto *FooLoc = cast<ScalarStorageLocation>(
- Env.getStorageLocation(*FooDecl, SkipPast::None));
+ const auto *FooLoc =
+ cast<ScalarStorageLocation>(Env.getStorageLocation(*FooDecl));
const auto *BarVal =
cast<PointerValue>(Env.getValue(*BarDecl, SkipPast::None));
EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc);
More information about the cfe-commits
mailing list