This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97d69cdaf324: [clang][dataflow] Rename `getPointeeLoc` to
`getReferentLoc` for ReferenceValue. (authored by wyt, committed by gribozavr).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127745/new/
https://reviews.llvm.org/D127745
Files:
clang/include/clang/Analysis/FlowSensitive/Value.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===================================================================
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -293,29 +293,29 @@
// [[p]]
}
)";
- runDataflow(Code,
- [](llvm::ArrayRef<
- std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
- Results,
- ASTContext &ASTCtx) {
- ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
- const Environment &Env = Results[0].second.Env;
+ runDataflow(
+ Code, [](llvm::ArrayRef<
+ std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
+ Results,
+ ASTContext &ASTCtx) {
+ ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+ const Environment &Env = Results[0].second.Env;
- const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
- ASSERT_THAT(FooDecl, NotNull());
+ const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
- ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
+ const StorageLocation *FooLoc =
+ Env.getStorageLocation(*FooDecl, SkipPast::None);
+ ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
- const ReferenceValue *FooVal =
- cast<ReferenceValue>(Env.getValue(*FooLoc));
- const StorageLocation &FooPointeeLoc = FooVal->getPointeeLoc();
- EXPECT_TRUE(isa<AggregateStorageLocation>(&FooPointeeLoc));
+ const ReferenceValue *FooVal =
+ cast<ReferenceValue>(Env.getValue(*FooLoc));
+ const StorageLocation &FooReferentLoc = FooVal->getReferentLoc();
+ EXPECT_TRUE(isa<AggregateStorageLocation>(&FooReferentLoc));
- const Value *FooPointeeVal = Env.getValue(FooPointeeLoc);
- EXPECT_TRUE(isa_and_nonnull<StructValue>(FooPointeeVal));
- });
+ const Value *FooReferentVal = Env.getValue(FooReferentLoc);
+ EXPECT_TRUE(isa_and_nonnull<StructValue>(FooReferentVal));
+ });
}
TEST_F(TransferTest, SelfReferentialReferenceVarDecl) {
@@ -397,31 +397,31 @@
const auto *FooLoc = cast<ScalarStorageLocation>(
Env.getStorageLocation(*FooDecl, SkipPast::None));
const auto *FooVal = cast<ReferenceValue>(Env.getValue(*FooLoc));
- const auto *FooPointeeVal =
- cast<StructValue>(Env.getValue(FooVal->getPointeeLoc()));
+ const auto *FooReferentVal =
+ cast<StructValue>(Env.getValue(FooVal->getReferentLoc()));
const auto *BarVal =
- cast<ReferenceValue>(FooPointeeVal->getChild(*BarDecl));
- const auto *BarPointeeVal =
- cast<StructValue>(Env.getValue(BarVal->getPointeeLoc()));
+ cast<ReferenceValue>(FooReferentVal->getChild(*BarDecl));
+ const auto *BarReferentVal =
+ cast<StructValue>(Env.getValue(BarVal->getReferentLoc()));
const auto *FooRefVal =
- cast<ReferenceValue>(BarPointeeVal->getChild(*FooRefDecl));
- const StorageLocation &FooRefPointeeLoc = FooRefVal->getPointeeLoc();
- EXPECT_THAT(Env.getValue(FooRefPointeeLoc), IsNull());
+ cast<ReferenceValue>(BarReferentVal->getChild(*FooRefDecl));
+ const StorageLocation &FooReferentLoc = FooRefVal->getReferentLoc();
+ EXPECT_THAT(Env.getValue(FooReferentLoc), IsNull());
const auto *FooPtrVal =
- cast<PointerValue>(BarPointeeVal->getChild(*FooPtrDecl));
+ cast<PointerValue>(BarReferentVal->getChild(*FooPtrDecl));
const StorageLocation &FooPtrPointeeLoc = FooPtrVal->getPointeeLoc();
EXPECT_THAT(Env.getValue(FooPtrPointeeLoc), IsNull());
const auto *BazRefVal =
- cast<ReferenceValue>(BarPointeeVal->getChild(*BazRefDecl));
- const StorageLocation &BazRefPointeeLoc = BazRefVal->getPointeeLoc();
- EXPECT_THAT(Env.getValue(BazRefPointeeLoc), NotNull());
+ cast<ReferenceValue>(BarReferentVal->getChild(*BazRefDecl));
+ const StorageLocation &BazReferentLoc = BazRefVal->getReferentLoc();
+ EXPECT_THAT(Env.getValue(BazReferentLoc), NotNull());
const auto *BazPtrVal =
- cast<PointerValue>(BarPointeeVal->getChild(*BazPtrDecl));
+ cast<PointerValue>(BarReferentVal->getChild(*BazPtrDecl));
const StorageLocation &BazPtrPointeeLoc = BazPtrVal->getPointeeLoc();
EXPECT_THAT(Env.getValue(BazPtrPointeeLoc), NotNull());
});
@@ -564,8 +564,8 @@
const auto *FooRefVal =
cast<ReferenceValue>(BarPointeeVal->getChild(*FooRefDecl));
- const StorageLocation &FooRefPointeeLoc = FooRefVal->getPointeeLoc();
- EXPECT_THAT(Env.getValue(FooRefPointeeLoc), IsNull());
+ const StorageLocation &FooReferentLoc = FooRefVal->getReferentLoc();
+ EXPECT_THAT(Env.getValue(FooReferentLoc), IsNull());
const auto *FooPtrVal =
cast<PointerValue>(BarPointeeVal->getChild(*FooPtrDecl));
@@ -574,8 +574,8 @@
const auto *BazRefVal =
cast<ReferenceValue>(BarPointeeVal->getChild(*BazRefDecl));
- const StorageLocation &BazRefPointeeLoc = BazRefVal->getPointeeLoc();
- EXPECT_THAT(Env.getValue(BazRefPointeeLoc), NotNull());
+ const StorageLocation &BazReferentLoc = BazRefVal->getReferentLoc();
+ EXPECT_THAT(Env.getValue(BazReferentLoc), NotNull());
const auto *BazPtrVal =
cast<PointerValue>(BarPointeeVal->getChild(*BazPtrDecl));
@@ -952,31 +952,31 @@
// [[p]]
}
)";
- runDataflow(Code,
- [](llvm::ArrayRef<
- std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
- Results,
- ASTContext &ASTCtx) {
- ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
- const Environment &Env = Results[0].second.Env;
+ runDataflow(
+ Code, [](llvm::ArrayRef<
+ std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
+ Results,
+ ASTContext &ASTCtx) {
+ ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+ const Environment &Env = Results[0].second.Env;
- const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
- ASSERT_THAT(FooDecl, NotNull());
+ const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ ASSERT_THAT(FooDecl, NotNull());
- const StorageLocation *FooLoc =
- Env.getStorageLocation(*FooDecl, SkipPast::None);
- ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
+ const StorageLocation *FooLoc =
+ Env.getStorageLocation(*FooDecl, SkipPast::None);
+ ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(FooLoc));
- const ReferenceValue *FooVal =
- dyn_cast<ReferenceValue>(Env.getValue(*FooLoc));
- ASSERT_THAT(FooVal, NotNull());
+ const ReferenceValue *FooVal =
+ dyn_cast<ReferenceValue>(Env.getValue(*FooLoc));
+ ASSERT_THAT(FooVal, NotNull());
- const StorageLocation &FooPointeeLoc = FooVal->getPointeeLoc();
- EXPECT_TRUE(isa<AggregateStorageLocation>(&FooPointeeLoc));
+ const StorageLocation &FooReferentLoc = FooVal->getReferentLoc();
+ EXPECT_TRUE(isa<AggregateStorageLocation>(&FooReferentLoc));
- const Value *FooPointeeVal = Env.getValue(FooPointeeLoc);
- EXPECT_TRUE(isa_and_nonnull<StructValue>(FooPointeeVal));
- });
+ const Value *FooReferentVal = Env.getValue(FooReferentLoc);
+ EXPECT_TRUE(isa_and_nonnull<StructValue>(FooReferentVal));
+ });
}
TEST_F(TransferTest, PointerParamDecl) {
@@ -1378,13 +1378,13 @@
Env.getStorageLocation(*FooDecl, SkipPast::None));
const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal = cast<ReferenceValue>(FooVal->getChild(*BarDecl));
- const auto *BarPointeeVal =
- cast<IntegerValue>(Env.getValue(BarVal->getPointeeLoc()));
+ const auto *BarReferentVal =
+ cast<IntegerValue>(Env.getValue(BarVal->getReferentLoc()));
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
- EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), BarPointeeVal);
+ EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), BarReferentVal);
});
}
@@ -1752,7 +1752,7 @@
const auto *QuxVal =
cast<ReferenceValue>(Env.getValue(*QuxDecl, SkipPast::None));
- EXPECT_EQ(&QuxVal->getPointeeLoc(), &FooVal->getPointeeLoc());
+ EXPECT_EQ(&QuxVal->getReferentLoc(), &FooVal->getReferentLoc());
});
}
@@ -2299,7 +2299,7 @@
cast<PointerValue>(Env.getValue(*FooDecl, SkipPast::None));
const auto *BarVal =
cast<ReferenceValue>(Env.getValue(*BarDecl, SkipPast::None));
- EXPECT_EQ(&BarVal->getPointeeLoc(), &FooVal->getPointeeLoc());
+ EXPECT_EQ(&BarVal->getReferentLoc(), &FooVal->getPointeeLoc());
});
}
Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -236,7 +236,7 @@
// `Value` representing the optional (here, `OptionalVal`).
if (auto *ValueProp = OptionalVal.getProperty("value")) {
auto *ValueRef = clang::cast<ReferenceValue>(ValueProp);
- auto &ValueLoc = ValueRef->getPointeeLoc();
+ auto &ValueLoc = ValueRef->getReferentLoc();
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
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -53,7 +53,7 @@
static bool areEquivalentIndirectionValues(Value *Val1, Value *Val2) {
if (auto *IndVal1 = dyn_cast<ReferenceValue>(Val1)) {
auto *IndVal2 = cast<ReferenceValue>(Val2);
- return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc();
+ return &IndVal1->getReferentLoc() == &IndVal2->getReferentLoc();
}
if (auto *IndVal1 = dyn_cast<PointerValue>(Val1)) {
auto *IndVal2 = cast<PointerValue>(Val2);
@@ -522,7 +522,7 @@
// References cannot be chained so we only need to skip past one level of
// indirection.
if (auto *Val = dyn_cast_or_null<ReferenceValue>(getValue(Loc)))
- return Val->getPointeeLoc();
+ return Val->getReferentLoc();
return Loc;
case SkipPast::ReferenceThenPointer:
StorageLocation &LocPastRef = skip(Loc, SkipPast::Reference);
Index: clang/include/clang/Analysis/FlowSensitive/Value.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/Value.h
+++ clang/include/clang/Analysis/FlowSensitive/Value.h
@@ -170,17 +170,17 @@
/// in C.
class ReferenceValue final : public Value {
public:
- explicit ReferenceValue(StorageLocation &PointeeLoc)
- : Value(Kind::Reference), PointeeLoc(PointeeLoc) {}
+ explicit ReferenceValue(StorageLocation &ReferentLoc)
+ : Value(Kind::Reference), ReferentLoc(ReferentLoc) {}
static bool classof(const Value *Val) {
return Val->getKind() == Kind::Reference;
}
- StorageLocation &getPointeeLoc() const { return PointeeLoc; }
+ StorageLocation &getReferentLoc() const { return ReferentLoc; }
private:
- StorageLocation &PointeeLoc;
+ StorageLocation &ReferentLoc;
};
/// Models a symbolic pointer. Specifically, any value of type `T*`.
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits