diff --git a/clang/include/clang/Analysis/FlowSensitive/Value.h b/clang/include/clang/Analysis/FlowSensitive/Value.h --- a/clang/include/clang/Analysis/FlowSensitive/Value.h +++ b/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*`. diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -53,7 +53,7 @@ static bool areEquivalentIndirectionValues(Value *Val1, Value *Val2) { if (auto *IndVal1 = dyn_cast(Val1)) { auto *IndVal2 = cast(Val2); - return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc(); + return &IndVal1->getReferentLoc() == &IndVal2->getReferentLoc(); } if (auto *IndVal1 = dyn_cast(Val1)) { auto *IndVal2 = cast(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(getValue(Loc))) - return Val->getPointeeLoc(); + return Val->getReferentLoc(); return Loc; case SkipPast::ReferenceThenPointer: StorageLocation &LocPastRef = skip(Loc, SkipPast::Reference); diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/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(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 diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -293,29 +293,29 @@ // [[p]] } )"; - runDataflow(Code, - [](llvm::ArrayRef< - std::pair>> - Results, - ASTContext &ASTCtx) { - ASSERT_THAT(Results, ElementsAre(Pair("p", _))); - const Environment &Env = Results[0].second.Env; + runDataflow( + Code, [](llvm::ArrayRef< + std::pair>> + 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(FooLoc)); + const StorageLocation *FooLoc = + Env.getStorageLocation(*FooDecl, SkipPast::None); + ASSERT_TRUE(isa_and_nonnull(FooLoc)); - const ReferenceValue *FooVal = - cast(Env.getValue(*FooLoc)); - const StorageLocation &FooPointeeLoc = FooVal->getPointeeLoc(); - EXPECT_TRUE(isa(&FooPointeeLoc)); + const ReferenceValue *FooVal = + cast(Env.getValue(*FooLoc)); + const StorageLocation &FooReferentLoc = FooVal->getReferentLoc(); + EXPECT_TRUE(isa(&FooReferentLoc)); - const Value *FooPointeeVal = Env.getValue(FooPointeeLoc); - EXPECT_TRUE(isa_and_nonnull(FooPointeeVal)); - }); + const Value *FooReferentVal = Env.getValue(FooReferentLoc); + EXPECT_TRUE(isa_and_nonnull(FooReferentVal)); + }); } TEST_F(TransferTest, SelfReferentialReferenceVarDecl) { @@ -397,31 +397,31 @@ const auto *FooLoc = cast( Env.getStorageLocation(*FooDecl, SkipPast::None)); const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *FooPointeeVal = - cast(Env.getValue(FooVal->getPointeeLoc())); + const auto *FooReferentVal = + cast(Env.getValue(FooVal->getReferentLoc())); const auto *BarVal = - cast(FooPointeeVal->getChild(*BarDecl)); - const auto *BarPointeeVal = - cast(Env.getValue(BarVal->getPointeeLoc())); + cast(FooReferentVal->getChild(*BarDecl)); + const auto *BarReferentVal = + cast(Env.getValue(BarVal->getReferentLoc())); const auto *FooRefVal = - cast(BarPointeeVal->getChild(*FooRefDecl)); - const StorageLocation &FooRefPointeeLoc = FooRefVal->getPointeeLoc(); - EXPECT_THAT(Env.getValue(FooRefPointeeLoc), IsNull()); + cast(BarReferentVal->getChild(*FooRefDecl)); + const StorageLocation &FooReferentLoc = FooRefVal->getReferentLoc(); + EXPECT_THAT(Env.getValue(FooReferentLoc), IsNull()); const auto *FooPtrVal = - cast(BarPointeeVal->getChild(*FooPtrDecl)); + cast(BarReferentVal->getChild(*FooPtrDecl)); const StorageLocation &FooPtrPointeeLoc = FooPtrVal->getPointeeLoc(); EXPECT_THAT(Env.getValue(FooPtrPointeeLoc), IsNull()); const auto *BazRefVal = - cast(BarPointeeVal->getChild(*BazRefDecl)); - const StorageLocation &BazRefPointeeLoc = BazRefVal->getPointeeLoc(); - EXPECT_THAT(Env.getValue(BazRefPointeeLoc), NotNull()); + cast(BarReferentVal->getChild(*BazRefDecl)); + const StorageLocation &BazReferentLoc = BazRefVal->getReferentLoc(); + EXPECT_THAT(Env.getValue(BazReferentLoc), NotNull()); const auto *BazPtrVal = - cast(BarPointeeVal->getChild(*BazPtrDecl)); + cast(BarReferentVal->getChild(*BazPtrDecl)); const StorageLocation &BazPtrPointeeLoc = BazPtrVal->getPointeeLoc(); EXPECT_THAT(Env.getValue(BazPtrPointeeLoc), NotNull()); }); @@ -564,8 +564,8 @@ const auto *FooRefVal = cast(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(BarPointeeVal->getChild(*FooPtrDecl)); @@ -574,8 +574,8 @@ const auto *BazRefVal = cast(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(BarPointeeVal->getChild(*BazPtrDecl)); @@ -952,31 +952,31 @@ // [[p]] } )"; - runDataflow(Code, - [](llvm::ArrayRef< - std::pair>> - Results, - ASTContext &ASTCtx) { - ASSERT_THAT(Results, ElementsAre(Pair("p", _))); - const Environment &Env = Results[0].second.Env; + runDataflow( + Code, [](llvm::ArrayRef< + std::pair>> + 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(FooLoc)); + const StorageLocation *FooLoc = + Env.getStorageLocation(*FooDecl, SkipPast::None); + ASSERT_TRUE(isa_and_nonnull(FooLoc)); - const ReferenceValue *FooVal = - dyn_cast(Env.getValue(*FooLoc)); - ASSERT_THAT(FooVal, NotNull()); + const ReferenceValue *FooVal = + dyn_cast(Env.getValue(*FooLoc)); + ASSERT_THAT(FooVal, NotNull()); - const StorageLocation &FooPointeeLoc = FooVal->getPointeeLoc(); - EXPECT_TRUE(isa(&FooPointeeLoc)); + const StorageLocation &FooReferentLoc = FooVal->getReferentLoc(); + EXPECT_TRUE(isa(&FooReferentLoc)); - const Value *FooPointeeVal = Env.getValue(FooPointeeLoc); - EXPECT_TRUE(isa_and_nonnull(FooPointeeVal)); - }); + const Value *FooReferentVal = Env.getValue(FooReferentLoc); + EXPECT_TRUE(isa_and_nonnull(FooReferentVal)); + }); } TEST_F(TransferTest, PointerParamDecl) { @@ -1378,13 +1378,13 @@ Env.getStorageLocation(*FooDecl, SkipPast::None)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(FooVal->getChild(*BarDecl)); - const auto *BarPointeeVal = - cast(Env.getValue(BarVal->getPointeeLoc())); + const auto *BarReferentVal = + cast(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(Env.getValue(*QuxDecl, SkipPast::None)); - EXPECT_EQ(&QuxVal->getPointeeLoc(), &FooVal->getPointeeLoc()); + EXPECT_EQ(&QuxVal->getReferentLoc(), &FooVal->getReferentLoc()); }); } @@ -2299,7 +2299,7 @@ cast(Env.getValue(*FooDecl, SkipPast::None)); const auto *BarVal = cast(Env.getValue(*BarDecl, SkipPast::None)); - EXPECT_EQ(&BarVal->getPointeeLoc(), &FooVal->getPointeeLoc()); + EXPECT_EQ(&BarVal->getReferentLoc(), &FooVal->getPointeeLoc()); }); }