diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -281,12 +281,7 @@ /// /// 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 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -245,7 +245,7 @@ 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 @@ } 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 @@ 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 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 --- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp +++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp @@ -219,7 +219,7 @@ 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 @@ if (auto *D = dyn_cast(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 --- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp @@ -218,8 +218,8 @@ // Verify the global variable is populated when we analyze `Target`. Environment Env(DAContext, *Fun); - const auto *GlobalLoc = cast( - Env.getStorageLocation(*GlobalDecl, SkipPast::None)); + const auto *GlobalLoc = + cast(Env.getStorageLocation(*GlobalDecl)); const auto *GlobalVal = cast(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 --- a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp @@ -88,8 +88,7 @@ LatticeTransferState &State) { const auto *Var = M.Nodes.getNodeAs(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 @@ 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(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 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -99,7 +99,7 @@ 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 @@ 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(FooLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -148,8 +147,7 @@ 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(FooLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -228,8 +226,8 @@ } ASSERT_THAT(UnmodeledDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *UnmodeledLoc = &FooLoc->getChild(*UnmodeledDecl); ASSERT_TRUE(isa(UnmodeledLoc)); ASSERT_THAT(Env.getValue(*UnmodeledLoc), IsNull()); @@ -275,8 +273,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -323,8 +321,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -370,8 +368,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -402,8 +400,7 @@ 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(FooLoc)); const Value *FooReferentVal = Env.getValue(*FooLoc); @@ -490,8 +487,8 @@ ASSERT_THAT(BazRefDecl, NotNull()); ASSERT_THAT(BazPtrDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *FooReferentVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = @@ -546,8 +543,7 @@ 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(FooLoc)); const PointerValue *FooVal = cast(Env.getValue(*FooLoc)); @@ -651,8 +647,8 @@ ASSERT_THAT(BazRefDecl, NotNull()); ASSERT_THAT(BazPtrDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *FooPointeeVal = cast(Env.getValue(FooVal->getPointeeLoc())); @@ -705,12 +701,10 @@ 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(FooLoc)); - const StorageLocation *BarLoc = - Env.getStorageLocation(*BarDecl, SkipPast::None); + const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl); ASSERT_TRUE(isa_and_nonnull(BarLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -753,26 +747,25 @@ 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 @@ 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(FooLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -981,8 +973,7 @@ 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(BarLoc)); const Value *BarVal = Env.getValue(*BarLoc); @@ -1024,8 +1015,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -1054,8 +1045,7 @@ 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(FooLoc)); const Value *FooReferentVal = Env.getValue(*FooLoc); @@ -1082,8 +1072,7 @@ 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(FooLoc)); const PointerValue *FooVal = cast(Env.getValue(*FooLoc)); @@ -1129,8 +1118,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(FooVal->getChild(*BarDecl)); @@ -1260,8 +1249,8 @@ ASSERT_THAT(APrivateDecl, NotNull()); ASSERT_THAT(APublicDecl, NotNull()); - const auto &FooLoc = *cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto &FooLoc = + *cast(Env.getStorageLocation(*FooDecl)); const auto &FooVal = *cast(Env.getValue(FooLoc)); // Note: we can't test presence of children in `FooLoc`, because @@ -1319,8 +1308,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto &FooLoc = *cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto &FooLoc = + *cast(Env.getStorageLocation(*FooDecl)); const auto &FooVal = *cast(Env.getValue(FooLoc)); EXPECT_THAT(FooVal.getChild(*BarDecl), NotNull()); EXPECT_EQ(Env.getValue(FooLoc.getChild(*BarDecl)), FooVal.getChild(*BarDecl)); @@ -1399,8 +1388,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(FooVal->getChild(*BarDecl)); @@ -1489,8 +1478,8 @@ } ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(FooVal->getChild(*BarDecl)); const auto *BarReferentVal = @@ -1931,8 +1920,8 @@ const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -1969,8 +1958,8 @@ const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarLoc = cast(&FooLoc->getChild(*BarDecl)); @@ -2013,10 +2002,10 @@ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooLoc1 = cast( - Env1.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc1 = cast( - Env1.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc1 = + cast(Env1.getStorageLocation(*FooDecl)); + const auto *BarLoc1 = + cast(Env1.getStorageLocation(*BarDecl)); const auto *FooVal1 = cast(Env1.getValue(*FooLoc1)); const auto *BarVal1 = cast(Env1.getValue(*BarLoc1)); @@ -2028,10 +2017,10 @@ cast(Env1.getValue(BarLoc1->getChild(*BazDecl))); EXPECT_NE(FooBazVal1, BarBazVal1); - const auto *FooLoc2 = cast( - Env2.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc2 = cast( - Env2.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc2 = + cast(Env2.getStorageLocation(*FooDecl)); + const auto *BarLoc2 = + cast(Env2.getStorageLocation(*BarDecl)); const auto *FooVal2 = cast(Env2.getValue(*FooLoc2)); const auto *BarVal2 = cast(Env2.getValue(*BarLoc2)); @@ -2074,10 +2063,10 @@ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc = cast( - Env.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); + const auto *BarLoc = + cast(Env.getStorageLocation(*BarDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(Env.getValue(*BarLoc)); @@ -2122,10 +2111,10 @@ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc = cast( - Env.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); + const auto *BarLoc = + cast(Env.getStorageLocation(*BarDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(Env.getValue(*BarLoc)); @@ -2168,10 +2157,10 @@ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc = cast( - Env.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); + const auto *BarLoc = + cast(Env.getStorageLocation(*BarDecl)); const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = cast(Env.getValue(*BarLoc)); @@ -2231,10 +2220,10 @@ const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooLoc1 = cast( - Env1.getStorageLocation(*FooDecl, SkipPast::None)); - const auto *BarLoc1 = cast( - Env1.getStorageLocation(*BarDecl, SkipPast::None)); + const auto *FooLoc1 = + cast(Env1.getStorageLocation(*FooDecl)); + const auto *BarLoc1 = + cast(Env1.getStorageLocation(*BarDecl)); const auto *FooVal1 = cast(Env1.getValue(*FooLoc1)); const auto *BarVal1 = cast(Env1.getValue(*BarLoc1)); @@ -2246,8 +2235,8 @@ cast(Env1.getValue(BarLoc1->getChild(*BazDecl))); EXPECT_NE(FooBazVal1, BarBazVal1); - const auto *FooLoc2 = cast( - Env2.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc2 = + cast(Env2.getStorageLocation(*FooDecl)); const auto *FooVal2 = cast(Env2.getValue(*FooLoc2)); EXPECT_EQ(FooVal2, BarVal1); @@ -2523,8 +2512,8 @@ const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarVal = cast(Env.getValue(*BarDecl, SkipPast::None)); EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc); @@ -2806,7 +2795,7 @@ ASSERT_THAT(FooDecl, NotNull()); const auto *BazLoc = dyn_cast_or_null( - Env.getStorageLocation(*BazDecl, SkipPast::None)); + Env.getStorageLocation(*BazDecl)); ASSERT_THAT(BazLoc, NotNull()); ASSERT_THAT(Env.getValue(*BazLoc), NotNull()); @@ -2817,7 +2806,7 @@ 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(BarLoc)); EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazVal); @@ -3221,8 +3210,7 @@ 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(FooLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -3251,12 +3239,10 @@ 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(FooLoc)); - const StorageLocation *BarLoc = - Env.getStorageLocation(*BarDecl, SkipPast::None); + const StorageLocation *BarLoc = Env.getStorageLocation(*BarDecl); ASSERT_TRUE(isa_and_nonnull(BarLoc)); const Value *FooVal = Env.getValue(*FooLoc); @@ -3671,7 +3657,7 @@ ASSERT_THAT(LVal, NotNull()); EXPECT_EQ(&LVal->getPointeeLoc(), - InnerEnv.getStorageLocation(*ValDecl, SkipPast::Reference)); + InnerEnv.getStorageLocation(*ValDecl)); // Outer. LVal = @@ -3681,7 +3667,7 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 --- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp @@ -723,8 +723,8 @@ const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooLoc = cast( - Env.getStorageLocation(*FooDecl, SkipPast::None)); + const auto *FooLoc = + cast(Env.getStorageLocation(*FooDecl)); const auto *BarVal = cast(Env.getValue(*BarDecl, SkipPast::None)); EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc);