diff --git a/clang/include/clang/Analysis/FlowSensitive/Value.h b/clang/include/clang/Analysis/FlowSensitive/Value.h index 3ac4b8c60996b..9c93456346b23 100644 --- a/clang/include/clang/Analysis/FlowSensitive/Value.h +++ b/clang/include/clang/Analysis/FlowSensitive/Value.h @@ -170,17 +170,17 @@ class IntegerValue : public Value { /// 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 index 033ef6afbeb2f..370b420b80755 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -53,7 +53,7 @@ llvm::DenseMap intersectDenseMaps(const llvm::DenseMap &Map1, 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 @@ StorageLocation &Environment::skip(StorageLocation &Loc, SkipPast SP) const { // 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 index f837fe31c6cd8..23a9d964b5b15 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -236,7 +236,7 @@ StorageLocation *maybeInitializeOptionalValueMember(QualType Q, // `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 index 5780968d81591..e3c97367b17ca 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -293,29 +293,29 @@ TEST_F(TransferTest, ReferenceVarDecl) { // [[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 @@ TEST_F(TransferTest, SelfReferentialReferenceVarDecl) { 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 @@ TEST_F(TransferTest, SelfReferentialPointerVarDecl) { 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 @@ TEST_F(TransferTest, SelfReferentialPointerVarDecl) { 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 @@ TEST_F(TransferTest, ReferenceParamDecl) { // [[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 @@ TEST_F(TransferTest, ReferenceMember) { 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 @@ TEST_F(TransferTest, DefaultInitializerReference) { 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 @@ TEST_F(TransferTest, DerefDependentPtr) { 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()); }); }