diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h index 7f24755d9923a..c23e0db7f82d3 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -314,11 +314,7 @@ class Environment { /// Equivalent to `getValue(getStorageLocation(D, SP), SkipPast::None)` if `D` /// is assigned a storage location in the environment, otherwise returns null. - /// - /// 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`. - Value *getValue(const ValueDecl &D, SkipPast SP = SkipPast::None) const; + Value *getValue(const ValueDecl &D) const; /// Equivalent to `getValue(getStorageLocation(E, SP), SkipPast::None)` if `E` /// is assigned a storage location in the environment, otherwise returns null. diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index 479aa12d191ee..0d269f503f4eb 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -680,9 +680,7 @@ Value *Environment::getValue(const StorageLocation &Loc) const { return It == LocToVal.end() ? nullptr : It->second; } -Value *Environment::getValue(const ValueDecl &D, SkipPast SP) const { - assert(SP != SkipPast::ReferenceThenPointer); - +Value *Environment::getValue(const ValueDecl &D) const { auto *Loc = getStorageLocation(D); if (Loc == nullptr) return nullptr; diff --git a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp index 86feca486ec7c..f88a179f93a45 100644 --- a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp @@ -158,7 +158,7 @@ TEST(ChromiumCheckModelTest, CheckSuccessImpliesConditionHolds) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto *FooVal = cast(Env.getValue(*FooDecl, SkipPast::None)); + auto *FooVal = cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(*FooVal)); }; @@ -189,7 +189,7 @@ TEST(ChromiumCheckModelTest, UnrelatedCheckIgnored) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto *FooVal = cast(Env.getValue(*FooDecl, SkipPast::None)); + auto *FooVal = cast(Env.getValue(*FooDecl)); EXPECT_FALSE(Env.flowConditionImplies(*FooVal)); }; diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp index 2f874b44c49bf..1c78dd380c774 100644 --- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp @@ -124,7 +124,7 @@ TEST_F(EnvironmentTest, InitGlobalVarsFun) { // Verify the global variable is populated when we analyze `Target`. Environment Env(DAContext, *Fun); - EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull()); + EXPECT_THAT(Env.getValue(*Var), NotNull()); } // Tests that fields mentioned only in default member initializers are included @@ -255,7 +255,7 @@ TEST_F(EnvironmentTest, InitGlobalVarsConstructor) { // Verify the global variable is populated when we analyze `Target`. Environment Env(DAContext, *Ctor); - EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull()); + EXPECT_THAT(Env.getValue(*Var), NotNull()); } } // namespace diff --git a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp index 9a5a7fd0b5532..325ffe1af9914 100644 --- a/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp @@ -109,7 +109,7 @@ getValueAndSignProperties(const UnaryOperator *UO, // The DeclRefExpr refers to this variable in the operand. const auto *OperandVar = M.Nodes.getNodeAs(kVar); assert(OperandVar != nullptr); - const auto *OperandValue = State.Env.getValue(*OperandVar, SkipPast::None); + const auto *OperandValue = State.Env.getValue(*OperandVar); if (!OperandValue) return {nullptr, {}, {}}; diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h index ef67dc98790c0..e1a56b049f6de 100644 --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h +++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h @@ -400,7 +400,7 @@ ValueT &getValueForDecl(ASTContext &ASTCtx, const Environment &Env, llvm::StringRef Name) { const ValueDecl *VD = findValueDecl(ASTCtx, Name); assert(VD != nullptr); - return *cast(Env.getValue(*VD, SkipPast::None)); + return *cast(Env.getValue(*VD)); } /// Creates and owns constraints which are boolean values. diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index d2e86c5211975..54d3c5751b23b 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -173,8 +173,7 @@ TEST(TransferTest, StructIncomplete) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto *FooValue = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + auto *FooValue = dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooValue, NotNull()); EXPECT_TRUE(isa(FooValue->getPointeeLoc())); @@ -234,7 +233,7 @@ TEST(TransferTest, StructFieldUnmodeled) { const ValueDecl *ZabDecl = findValueDecl(ASTCtx, "Zab"); ASSERT_THAT(ZabDecl, NotNull()); - EXPECT_THAT(Env.getValue(*ZabDecl, SkipPast::None), NotNull()); + EXPECT_THAT(Env.getValue(*ZabDecl), NotNull()); }); } @@ -788,13 +787,13 @@ TEST(TransferTest, BinaryOperatorAssign) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const Value *FooVal = Env.getValue(*FooDecl, SkipPast::None); + const Value *FooVal = Env.getValue(*FooDecl); ASSERT_TRUE(isa_and_nonnull(FooVal)); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BarDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*BarDecl), FooVal); }); } @@ -816,13 +815,13 @@ TEST(TransferTest, VarDeclInitAssign) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const Value *FooVal = Env.getValue(*FooDecl, SkipPast::None); + const Value *FooVal = Env.getValue(*FooDecl); ASSERT_TRUE(isa_and_nonnull(FooVal)); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BarDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*BarDecl), FooVal); }); } @@ -845,7 +844,7 @@ TEST(TransferTest, VarDeclInitAssignChained) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const Value *FooVal = Env.getValue(*FooDecl, SkipPast::None); + const Value *FooVal = Env.getValue(*FooDecl); ASSERT_TRUE(isa_and_nonnull(FooVal)); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); @@ -854,8 +853,8 @@ TEST(TransferTest, VarDeclInitAssignChained) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BarDecl, SkipPast::None), FooVal); - EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*BarDecl), FooVal); + EXPECT_EQ(Env.getValue(*BazDecl), FooVal); }); } @@ -879,20 +878,19 @@ TEST(TransferTest, VarDeclInitAssignPtrDeref) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const Value *FooVal = Env.getValue(*FooDecl, SkipPast::None); + const Value *FooVal = Env.getValue(*FooDecl); ASSERT_TRUE(isa_and_nonnull(FooVal)); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); EXPECT_EQ(Env.getValue(BarVal->getPointeeLoc()), FooVal); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*BazDecl), FooVal); }); } @@ -920,30 +918,30 @@ TEST(TransferTest, AssignToAndFromReference) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const Value *FooVal = Env1.getValue(*FooDecl, SkipPast::None); + const Value *FooVal = Env1.getValue(*FooDecl); ASSERT_TRUE(isa_and_nonnull(FooVal)); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const Value *BarVal = Env1.getValue(*BarDecl, SkipPast::None); + const Value *BarVal = Env1.getValue(*BarDecl); ASSERT_TRUE(isa_and_nonnull(BarVal)); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env1.getValue(*BazDecl, SkipPast::Reference), FooVal); + EXPECT_EQ(Env1.getValue(*BazDecl), FooVal); - EXPECT_EQ(Env2.getValue(*BazDecl, SkipPast::Reference), BarVal); - EXPECT_EQ(Env2.getValue(*FooDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env2.getValue(*BazDecl), BarVal); + EXPECT_EQ(Env2.getValue(*FooDecl), BarVal); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); - EXPECT_EQ(Env2.getValue(*QuxDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env2.getValue(*QuxDecl), BarVal); const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); - EXPECT_EQ(Env2.getValue(*QuuxDecl, SkipPast::Reference), BarVal); + EXPECT_EQ(Env2.getValue(*QuuxDecl), BarVal); }); } @@ -1126,7 +1124,7 @@ TEST(TransferTest, StructMember) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*BazDecl), BarVal); }); } @@ -1396,7 +1394,7 @@ TEST(TransferTest, ClassMember) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*BazDecl), BarVal); }); } @@ -1488,7 +1486,7 @@ TEST(TransferTest, ReferenceMember) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - EXPECT_EQ(Env.getValue(*BazDecl, SkipPast::None), BarReferentVal); + EXPECT_EQ(Env.getValue(*BazDecl), BarReferentVal); }); } @@ -1533,7 +1531,7 @@ TEST(TransferTest, StructThisMember) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*FooDecl), BarVal); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); @@ -1563,7 +1561,7 @@ TEST(TransferTest, StructThisMember) { const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); - EXPECT_EQ(Env.getValue(*QuuxDecl, SkipPast::None), BazVal); + EXPECT_EQ(Env.getValue(*QuuxDecl), BazVal); }); } @@ -1608,7 +1606,7 @@ TEST(TransferTest, ClassThisMember) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*FooDecl), BarVal); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); @@ -1638,7 +1636,7 @@ TEST(TransferTest, ClassThisMember) { const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); - EXPECT_EQ(Env.getValue(*QuuxDecl, SkipPast::None), BazVal); + EXPECT_EQ(Env.getValue(*QuuxDecl), BazVal); }); } @@ -1726,7 +1724,7 @@ TEST(TransferTest, StructThisInLambda) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*FooDecl), BarVal); }, LangStandard::lang_cxx17, /*ApplyBuiltinTransfer=*/true, "operator()"); @@ -1765,7 +1763,7 @@ TEST(TransferTest, StructThisInLambda) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), BarVal); + EXPECT_EQ(Env.getValue(*FooDecl), BarVal); }, LangStandard::lang_cxx17, /*ApplyBuiltinTransfer=*/true, "operator()"); @@ -1815,12 +1813,11 @@ TEST(TransferTest, ConstructorInitializer) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = - cast(Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = cast(Env.getValue(*FooDecl)); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); - EXPECT_EQ(Env.getValue(*QuxDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*QuxDecl), FooVal); }); } @@ -1850,12 +1847,11 @@ TEST(TransferTest, DefaultInitializer) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = - cast(Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = cast(Env.getValue(*FooDecl)); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); - EXPECT_EQ(Env.getValue(*QuxDecl, SkipPast::None), FooVal); + EXPECT_EQ(Env.getValue(*QuxDecl), FooVal); }); } @@ -2275,10 +2271,8 @@ TEST(TransferTest, BindTemporary) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto &FooVal = - *cast(Env.getValue(*FooDecl, SkipPast::None)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto &FooVal = *cast(Env.getValue(*FooDecl)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); EXPECT_EQ(BarVal, FooVal.getChild(*BazDecl)); }); } @@ -2303,8 +2297,8 @@ TEST(TransferTest, StaticCast) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = Env.getValue(*FooDecl, SkipPast::None); - const auto *BarVal = Env.getValue(*BarDecl, SkipPast::None); + const auto *FooVal = Env.getValue(*FooDecl); + const auto *BarVal = Env.getValue(*BarDecl); EXPECT_TRUE(isa(FooVal)); EXPECT_TRUE(isa(BarVal)); EXPECT_EQ(FooVal, BarVal); @@ -2331,8 +2325,8 @@ TEST(TransferTest, IntegralCast) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = Env.getValue(*FooDecl, SkipPast::None); - const auto *BarVal = Env.getValue(*BarDecl, SkipPast::None); + const auto *FooVal = Env.getValue(*FooDecl); + const auto *BarVal = Env.getValue(*BarDecl); EXPECT_TRUE(isa(FooVal)); EXPECT_TRUE(isa(BarVal)); EXPECT_EQ(FooVal, BarVal); @@ -2359,8 +2353,8 @@ TEST(TransferTest, IntegraltoBooleanCast) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = Env.getValue(*FooDecl, SkipPast::None); - const auto *BarVal = Env.getValue(*BarDecl, SkipPast::None); + const auto *FooVal = Env.getValue(*FooDecl); + const auto *BarVal = Env.getValue(*BarDecl); EXPECT_TRUE(isa(FooVal)); EXPECT_TRUE(isa(BarVal)); }); @@ -2387,8 +2381,8 @@ TEST(TransferTest, IntegralToBooleanCastFromBool) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = Env.getValue(*FooDecl, SkipPast::None); - const auto *BarVal = Env.getValue(*BarDecl, SkipPast::None); + const auto *FooVal = Env.getValue(*FooDecl); + const auto *BarVal = Env.getValue(*BarDecl); EXPECT_TRUE(isa(FooVal)); EXPECT_TRUE(isa(BarVal)); EXPECT_EQ(FooVal, BarVal); @@ -2430,16 +2424,11 @@ TEST(TransferTest, NullToPointerCast) { const ValueDecl *NullDecl = findValueDecl(ASTCtx, "Null"); ASSERT_THAT(NullDecl, NotNull()); - const auto *FooXVal = - cast(Env.getValue(*FooXDecl, SkipPast::None)); - const auto *FooYVal = - cast(Env.getValue(*FooYDecl, SkipPast::None)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); - const auto *BazVal = - cast(Env.getValue(*BazDecl, SkipPast::None)); - const auto *NullVal = - cast(Env.getValue(*NullDecl, SkipPast::None)); + const auto *FooXVal = cast(Env.getValue(*FooXDecl)); + const auto *FooYVal = cast(Env.getValue(*FooYDecl)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); + const auto *BazVal = cast(Env.getValue(*BazDecl)); + const auto *NullVal = cast(Env.getValue(*NullDecl)); EXPECT_EQ(FooXVal, FooYVal); EXPECT_NE(FooXVal, BarVal); @@ -2483,8 +2472,8 @@ TEST(TransferTest, NullToMemberPointerCast) { findValueDecl(ASTCtx, "MemberPointer"); ASSERT_THAT(MemberPointerDecl, NotNull()); - const auto *MemberPointerVal = cast( - Env.getValue(*MemberPointerDecl, SkipPast::None)); + const auto *MemberPointerVal = + cast(Env.getValue(*MemberPointerDecl)); const StorageLocation &MemberLoc = MemberPointerVal->getPointeeLoc(); EXPECT_THAT(Env.getValue(MemberLoc), IsNull()); @@ -2514,8 +2503,7 @@ TEST(TransferTest, AddrOfValue) { const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc); }); } @@ -2540,10 +2528,8 @@ TEST(TransferTest, AddrOfReference) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = - cast(Env.getValue(*FooDecl, SkipPast::None)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *FooVal = cast(Env.getValue(*FooDecl)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); EXPECT_EQ(&BarVal->getPointeeLoc(), &FooVal->getPointeeLoc()); }); } @@ -2569,8 +2555,7 @@ TEST(TransferTest, DerefDependentPtr) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *FooVal = - cast(Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = cast(Env.getValue(*FooDecl)); const auto *BarLoc = Env.getStorageLocation(*BarDecl); EXPECT_EQ(BarLoc, &FooVal->getPointeeLoc()); }); @@ -2601,13 +2586,10 @@ TEST(TransferTest, VarDeclInitAssignConditionalOperator) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *FooVal = - cast(Env.getValue(*FooDecl, SkipPast::None)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *FooVal = cast(Env.getValue(*FooDecl)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); - const auto *BazVal = - dyn_cast(Env.getValue(*BazDecl, SkipPast::None)); + const auto *BazVal = dyn_cast(Env.getValue(*BazDecl)); ASSERT_THAT(BazVal, NotNull()); EXPECT_NE(BazVal, FooVal); @@ -2739,15 +2721,11 @@ TEST(TransferTest, AggregateInitialization) { const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); - const auto *FooArgVal = - cast(Env.getValue(*FooArgDecl, SkipPast::None)); - const auto *BarArgVal = - cast(Env.getValue(*BarArgDecl, SkipPast::None)); - const auto *QuxArgVal = - cast(Env.getValue(*QuxArgDecl, SkipPast::None)); + const auto *FooArgVal = cast(Env.getValue(*FooArgDecl)); + const auto *BarArgVal = cast(Env.getValue(*BarArgDecl)); + const auto *QuxArgVal = cast(Env.getValue(*QuxArgDecl)); - const auto *QuuxVal = - cast(Env.getValue(*QuuxDecl, SkipPast::None)); + const auto *QuuxVal = cast(Env.getValue(*QuuxDecl)); ASSERT_THAT(QuuxVal, NotNull()); const auto *BazVal = cast(QuuxVal->getChild(*BazDecl)); @@ -2832,15 +2810,15 @@ TEST(TransferTest, AssignFromBoolLiteral) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = + dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *BarVal = dyn_cast_or_null( - Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = + dyn_cast_or_null(Env.getValue(*BarDecl)); ASSERT_THAT(BarVal, NotNull()); EXPECT_EQ(FooVal, &Env.getBoolLiteralValue(true)); @@ -2866,29 +2844,29 @@ TEST(TransferTest, AssignFromCompositeBoolExpression) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = + dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *BarVal = dyn_cast_or_null( - Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = + dyn_cast_or_null(Env.getValue(*BarDecl)); ASSERT_THAT(BarVal, NotNull()); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); - const auto *QuxVal = dyn_cast_or_null( - Env.getValue(*QuxDecl, SkipPast::None)); + const auto *QuxVal = + dyn_cast_or_null(Env.getValue(*QuxDecl)); ASSERT_THAT(QuxVal, NotNull()); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *BazVal = dyn_cast_or_null( - Env.getValue(*BazDecl, SkipPast::None)); + const auto *BazVal = + dyn_cast_or_null(Env.getValue(*BazDecl)); ASSERT_THAT(BazVal, NotNull()); EXPECT_EQ(&BazVal->getLeftSubValue(), FooVal); @@ -2916,29 +2894,29 @@ TEST(TransferTest, AssignFromCompositeBoolExpression) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = + dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *BarVal = dyn_cast_or_null( - Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = + dyn_cast_or_null(Env.getValue(*BarDecl)); ASSERT_THAT(BarVal, NotNull()); const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux"); ASSERT_THAT(QuxDecl, NotNull()); - const auto *QuxVal = dyn_cast_or_null( - Env.getValue(*QuxDecl, SkipPast::None)); + const auto *QuxVal = + dyn_cast_or_null(Env.getValue(*QuxDecl)); ASSERT_THAT(QuxVal, NotNull()); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const auto *BazVal = dyn_cast_or_null( - Env.getValue(*BazDecl, SkipPast::None)); + const auto *BazVal = + dyn_cast_or_null(Env.getValue(*BazDecl)); ASSERT_THAT(BazVal, NotNull()); const auto *BazLeftSubValVal = @@ -2967,36 +2945,32 @@ TEST(TransferTest, AssignFromCompositeBoolExpression) { const ValueDecl *ADecl = findValueDecl(ASTCtx, "A"); ASSERT_THAT(ADecl, NotNull()); - const auto *AVal = - dyn_cast_or_null(Env.getValue(*ADecl, SkipPast::None)); + const auto *AVal = dyn_cast_or_null(Env.getValue(*ADecl)); ASSERT_THAT(AVal, NotNull()); const ValueDecl *BDecl = findValueDecl(ASTCtx, "B"); ASSERT_THAT(BDecl, NotNull()); - const auto *BVal = - dyn_cast_or_null(Env.getValue(*BDecl, SkipPast::None)); + const auto *BVal = dyn_cast_or_null(Env.getValue(*BDecl)); ASSERT_THAT(BVal, NotNull()); const ValueDecl *CDecl = findValueDecl(ASTCtx, "C"); ASSERT_THAT(CDecl, NotNull()); - const auto *CVal = - dyn_cast_or_null(Env.getValue(*CDecl, SkipPast::None)); + const auto *CVal = dyn_cast_or_null(Env.getValue(*CDecl)); ASSERT_THAT(CVal, NotNull()); const ValueDecl *DDecl = findValueDecl(ASTCtx, "D"); ASSERT_THAT(DDecl, NotNull()); - const auto *DVal = - dyn_cast_or_null(Env.getValue(*DDecl, SkipPast::None)); + const auto *DVal = dyn_cast_or_null(Env.getValue(*DDecl)); ASSERT_THAT(DVal, NotNull()); const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = + dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); const auto &FooLeftSubVal = @@ -3029,15 +3003,15 @@ TEST(TransferTest, AssignFromBoolNegation) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = dyn_cast_or_null( - Env.getValue(*FooDecl, SkipPast::None)); + const auto *FooVal = + dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - const auto *BarVal = dyn_cast_or_null( - Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = + dyn_cast_or_null(Env.getValue(*BarDecl)); ASSERT_THAT(BarVal, NotNull()); EXPECT_EQ(&BarVal->getSubVal(), FooVal); @@ -3064,8 +3038,7 @@ TEST(TransferTest, BuiltinExpect) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), - Env.getValue(*BarDecl, SkipPast::None)); + EXPECT_EQ(Env.getValue(*FooDecl), Env.getValue(*BarDecl)); }); } @@ -3092,8 +3065,7 @@ TEST(TransferTest, BuiltinExpectBoolArg) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), - Env.getValue(*BarDecl, SkipPast::None)); + EXPECT_EQ(Env.getValue(*FooDecl), Env.getValue(*BarDecl)); }); } @@ -3125,8 +3097,7 @@ TEST(TransferTest, BuiltinUnreachable) { // `__builtin_unreachable` promises that the code is // unreachable, so the compiler treats the "then" branch as the // only possible predecessor of this statement. - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), - Env.getValue(*BarDecl, SkipPast::None)); + EXPECT_EQ(Env.getValue(*FooDecl), Env.getValue(*BarDecl)); }); } @@ -3157,8 +3128,7 @@ TEST(TransferTest, BuiltinTrap) { // `__builtin_trap` ensures program termination, so only the // "then" branch is a predecessor of this statement. - EXPECT_EQ(Env.getValue(*FooDecl, SkipPast::None), - Env.getValue(*BarDecl, SkipPast::None)); + EXPECT_EQ(Env.getValue(*FooDecl), Env.getValue(*BarDecl)); }); } @@ -3188,8 +3158,7 @@ TEST(TransferTest, BuiltinDebugTrap) { ASSERT_THAT(BarDecl, NotNull()); // `__builtin_debugtrap` doesn't ensure program termination. - EXPECT_NE(Env.getValue(*FooDecl, SkipPast::None), - Env.getValue(*BarDecl, SkipPast::None)); + EXPECT_NE(Env.getValue(*FooDecl), Env.getValue(*BarDecl)); }); } @@ -3278,10 +3247,8 @@ TEST(TransferTest, GlobalIntVarDecl) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const Value *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); - const Value *BazVal = - cast(Env.getValue(*BazDecl, SkipPast::None)); + const Value *BarVal = cast(Env.getValue(*BarDecl)); + const Value *BazVal = cast(Env.getValue(*BazDecl)); EXPECT_EQ(BarVal, BazVal); }); } @@ -3311,10 +3278,8 @@ TEST(TransferTest, StaticMemberIntVarDecl) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const Value *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); - const Value *BazVal = - cast(Env.getValue(*BazDecl, SkipPast::None)); + const Value *BarVal = cast(Env.getValue(*BarDecl)); + const Value *BazVal = cast(Env.getValue(*BazDecl)); EXPECT_EQ(BarVal, BazVal); }); } @@ -3344,10 +3309,8 @@ TEST(TransferTest, StaticMemberRefVarDecl) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const Value *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); - const Value *BazVal = - cast(Env.getValue(*BazDecl, SkipPast::None)); + const Value *BarVal = cast(Env.getValue(*BarDecl)); + const Value *BazVal = cast(Env.getValue(*BazDecl)); EXPECT_EQ(BarVal, BazVal); }); } @@ -3386,11 +3349,9 @@ TEST(TransferTest, AssignMemberBeforeCopy) { const ValueDecl *A2Decl = findValueDecl(ASTCtx, "A2"); ASSERT_THAT(A2Decl, NotNull()); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); - const auto *A2Val = - cast(Env.getValue(*A2Decl, SkipPast::None)); + const auto *A2Val = cast(Env.getValue(*A2Decl)); EXPECT_EQ(A2Val->getChild(*FooDecl), BarVal); }); } @@ -3421,12 +3382,10 @@ TEST(TransferTest, BooleanEquality) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarValThen = - *cast(EnvThen.getValue(*BarDecl, SkipPast::None)); + auto &BarValThen = *cast(EnvThen.getValue(*BarDecl)); EXPECT_TRUE(EnvThen.flowConditionImplies(BarValThen)); - auto &BarValElse = - *cast(EnvElse.getValue(*BarDecl, SkipPast::None)); + auto &BarValElse = *cast(EnvElse.getValue(*BarDecl)); EXPECT_FALSE(EnvElse.flowConditionImplies(BarValElse)); }); } @@ -3457,12 +3416,10 @@ TEST(TransferTest, BooleanInequality) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarValThen = - *cast(EnvThen.getValue(*BarDecl, SkipPast::None)); + auto &BarValThen = *cast(EnvThen.getValue(*BarDecl)); EXPECT_FALSE(EnvThen.flowConditionImplies(BarValThen)); - auto &BarValElse = - *cast(EnvElse.getValue(*BarDecl, SkipPast::None)); + auto &BarValElse = *cast(EnvElse.getValue(*BarDecl)); EXPECT_TRUE(EnvElse.flowConditionImplies(BarValElse)); }); } @@ -3498,20 +3455,20 @@ TEST(TransferTest, CorrelatedBranches) { const Environment &Env = getEnvironmentAtAnnotation(Results, "p0"); const ValueDecl *BDecl = findValueDecl(ASTCtx, "B"); ASSERT_THAT(BDecl, NotNull()); - auto &BVal = *cast(Env.getValue(*BDecl, SkipPast::None)); + auto &BVal = *cast(Env.getValue(*BDecl)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BVal))); } { const Environment &Env = getEnvironmentAtAnnotation(Results, "p1"); - auto &CVal = *cast(Env.getValue(*CDecl, SkipPast::None)); + auto &CVal = *cast(Env.getValue(*CDecl)); EXPECT_TRUE(Env.flowConditionImplies(CVal)); } { const Environment &Env = getEnvironmentAtAnnotation(Results, "p2"); - auto &CVal = *cast(Env.getValue(*CDecl, SkipPast::None)); + auto &CVal = *cast(Env.getValue(*CDecl)); EXPECT_TRUE(Env.flowConditionImplies(CVal)); } }); @@ -3543,7 +3500,7 @@ TEST(TransferTest, LoopWithAssignmentConverges) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }); } @@ -3575,8 +3532,8 @@ TEST(TransferTest, LoopWithStagedAssignments) { const ValueDecl *ErrDecl = findValueDecl(ASTCtx, "Err"); ASSERT_THAT(ErrDecl, NotNull()); - auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None)); - auto &ErrVal = *cast(Env.getValue(*ErrDecl, SkipPast::None)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); + auto &ErrVal = *cast(Env.getValue(*ErrDecl)); EXPECT_TRUE(Env.flowConditionImplies(BarVal)); // An unsound analysis, for example only evaluating the loop once, can // conclude that `Err` is false. So, we test that this conclusion is not @@ -3610,8 +3567,7 @@ TEST(TransferTest, LoopWithReferenceAssignmentConverges) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarVal = - *cast(Env.getValue(*BarDecl, SkipPast::Reference)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }); } @@ -3652,16 +3608,14 @@ TEST(TransferTest, LoopWithStructReferenceAssignmentConverges) { ASSERT_THAT(LDecl, NotNull()); // Inner. - auto *LVal = - dyn_cast(InnerEnv.getValue(*LDecl, SkipPast::None)); + auto *LVal = dyn_cast(InnerEnv.getValue(*LDecl)); ASSERT_THAT(LVal, NotNull()); EXPECT_EQ(&LVal->getPointeeLoc(), InnerEnv.getStorageLocation(*ValDecl)); // Outer. - LVal = - dyn_cast(OuterEnv.getValue(*LDecl, SkipPast::None)); + LVal = dyn_cast(OuterEnv.getValue(*LDecl)); ASSERT_THAT(LVal, NotNull()); // The loop body may not have been executed, so we should not conclude @@ -3738,7 +3692,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToRefs) { const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl); ASSERT_THAT(BarRefLoc, NotNull()); - const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None); + const Value *QuxVal = Env.getValue(*QuxDecl); ASSERT_THAT(QuxVal, NotNull()); const StorageLocation *BoundFooRefLoc = @@ -3749,7 +3703,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToRefs) { Env.getStorageLocation(*BoundBarRefDecl); EXPECT_EQ(BoundBarRefLoc, BarRefLoc); - EXPECT_EQ(Env.getValue(*BoundFooRefDecl, SkipPast::Reference), QuxVal); + EXPECT_EQ(Env.getValue(*BoundFooRefDecl), QuxVal); }); } @@ -3797,7 +3751,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructRefMembersToRefs) { const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl); ASSERT_THAT(BarRefLoc, NotNull()); - const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None); + const Value *QuxVal = Env.getValue(*QuxDecl); ASSERT_THAT(QuxVal, NotNull()); const StorageLocation *BoundFooRefLoc = @@ -3808,7 +3762,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructRefMembersToRefs) { Env.getStorageLocation(*BoundBarRefDecl); EXPECT_EQ(BoundBarRefLoc, BarRefLoc); - EXPECT_EQ(Env.getValue(*BoundFooRefDecl, SkipPast::Reference), QuxVal); + EXPECT_EQ(Env.getValue(*BoundFooRefDecl), QuxVal); }); } @@ -3857,7 +3811,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToInts) { const StorageLocation *BarRefLoc = Env.getStorageLocation(*BarRefDecl); ASSERT_THAT(BarRefLoc, NotNull()); - const Value *QuxVal = Env.getValue(*QuxDecl, SkipPast::None); + const Value *QuxVal = Env.getValue(*QuxDecl); ASSERT_THAT(QuxVal, NotNull()); const StorageLocation *BoundFooLoc = @@ -3868,7 +3822,7 @@ TEST(TransferTest, StructuredBindingAssignFromStructIntMembersToInts) { Env.getStorageLocation(*BoundBarDecl); EXPECT_NE(BoundBarLoc, BarRefLoc); - EXPECT_EQ(Env.getValue(*BoundFooDecl, SkipPast::Reference), QuxVal); + EXPECT_EQ(Env.getValue(*BoundFooDecl), QuxVal); }); } @@ -3934,24 +3888,22 @@ TEST(TransferTest, StructuredBindingAssignFromTupleLikeType) { // BindingDecls always map to references -- either lvalue or rvalue, so // we still need to skip here. - const Value *BoundFooValue = - Env1.getValue(*BoundFooDecl, SkipPast::Reference); + const Value *BoundFooValue = Env1.getValue(*BoundFooDecl); ASSERT_THAT(BoundFooValue, NotNull()); EXPECT_TRUE(isa(BoundFooValue)); - const Value *BoundBarValue = - Env1.getValue(*BoundBarDecl, SkipPast::Reference); + const Value *BoundBarValue = Env1.getValue(*BoundBarDecl); ASSERT_THAT(BoundBarValue, NotNull()); EXPECT_TRUE(isa(BoundBarValue)); // Test that a `DeclRefExpr` to a `BindingDecl` works as expected. - EXPECT_EQ(Env1.getValue(*BazDecl, SkipPast::None), BoundFooValue); + EXPECT_EQ(Env1.getValue(*BazDecl), BoundFooValue); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); // Test that `BoundFooDecl` retains the value we expect, after the join. - BoundFooValue = Env2.getValue(*BoundFooDecl, SkipPast::Reference); - EXPECT_EQ(Env2.getValue(*BazDecl, SkipPast::None), BoundFooValue); + BoundFooValue = Env2.getValue(*BoundFooDecl); + EXPECT_EQ(Env2.getValue(*BazDecl), BoundFooValue); }); } @@ -4015,13 +3967,11 @@ TEST(TransferTest, StructuredBindingAssignRefFromTupleLikeType) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - const Value *BoundFooValue = - Env1.getValue(*BoundFooDecl, SkipPast::Reference); + const Value *BoundFooValue = Env1.getValue(*BoundFooDecl); ASSERT_THAT(BoundFooValue, NotNull()); EXPECT_TRUE(isa(BoundFooValue)); - const Value *BoundBarValue = - Env1.getValue(*BoundBarDecl, SkipPast::Reference); + const Value *BoundBarValue = Env1.getValue(*BoundBarDecl); ASSERT_THAT(BoundBarValue, NotNull()); EXPECT_TRUE(isa(BoundBarValue)); @@ -4029,13 +3979,13 @@ TEST(TransferTest, StructuredBindingAssignRefFromTupleLikeType) { // works as expected. We don't test aliasing properties of the // reference, because we don't model `std::get` and so have no way to // equate separate references into the tuple. - EXPECT_EQ(Env1.getValue(*BazDecl, SkipPast::None), BoundFooValue); + EXPECT_EQ(Env1.getValue(*BazDecl), BoundFooValue); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); // Test that `BoundFooDecl` retains the value we expect, after the join. - BoundFooValue = Env2.getValue(*BoundFooDecl, SkipPast::Reference); - EXPECT_EQ(Env2.getValue(*BazDecl, SkipPast::None), BoundFooValue); + BoundFooValue = Env2.getValue(*BoundFooDecl); + EXPECT_EQ(Env2.getValue(*BazDecl), BoundFooValue); }); } @@ -4092,12 +4042,10 @@ TEST(TransferTest, IfStmtBranchExtendsFlowCondition) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - BoolValue &ThenFooVal = - *cast(ThenEnv.getValue(*FooDecl, SkipPast::None)); + BoolValue &ThenFooVal = *cast(ThenEnv.getValue(*FooDecl)); EXPECT_TRUE(ThenEnv.flowConditionImplies(ThenFooVal)); - BoolValue &ElseFooVal = - *cast(ElseEnv.getValue(*FooDecl, SkipPast::None)); + BoolValue &ElseFooVal = *cast(ElseEnv.getValue(*FooDecl)); EXPECT_TRUE(ElseEnv.flowConditionImplies(ElseEnv.makeNot(ElseFooVal))); }); } @@ -4128,11 +4076,11 @@ TEST(TransferTest, WhileStmtBranchExtendsFlowCondition) { ASSERT_THAT(FooDecl, NotNull()); BoolValue &LoopBodyFooVal = - *cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None)); + *cast(LoopBodyEnv.getValue(*FooDecl)); EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal)); BoolValue &AfterLoopFooVal = - *cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None)); + *cast(AfterLoopEnv.getValue(*FooDecl)); EXPECT_TRUE(AfterLoopEnv.flowConditionImplies( AfterLoopEnv.makeNot(AfterLoopFooVal))); }); @@ -4169,16 +4117,16 @@ TEST(TransferTest, DoWhileStmtBranchExtendsFlowCondition) { ASSERT_THAT(BarDecl, NotNull()); BoolValue &LoopBodyFooVal = - *cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None)); + *cast(LoopBodyEnv.getValue(*FooDecl)); BoolValue &LoopBodyBarVal = - *cast(LoopBodyEnv.getValue(*BarDecl, SkipPast::None)); + *cast(LoopBodyEnv.getValue(*BarDecl)); EXPECT_TRUE(LoopBodyEnv.flowConditionImplies( LoopBodyEnv.makeOr(LoopBodyBarVal, LoopBodyFooVal))); BoolValue &AfterLoopFooVal = - *cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None)); + *cast(AfterLoopEnv.getValue(*FooDecl)); BoolValue &AfterLoopBarVal = - *cast(AfterLoopEnv.getValue(*BarDecl, SkipPast::None)); + *cast(AfterLoopEnv.getValue(*BarDecl)); EXPECT_TRUE(AfterLoopEnv.flowConditionImplies( AfterLoopEnv.makeNot(AfterLoopFooVal))); EXPECT_TRUE(AfterLoopEnv.flowConditionImplies( @@ -4212,11 +4160,11 @@ TEST(TransferTest, ForStmtBranchExtendsFlowCondition) { ASSERT_THAT(FooDecl, NotNull()); BoolValue &LoopBodyFooVal = - *cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None)); + *cast(LoopBodyEnv.getValue(*FooDecl)); EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal)); BoolValue &AfterLoopFooVal = - *cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None)); + *cast(AfterLoopEnv.getValue(*FooDecl)); EXPECT_TRUE(AfterLoopEnv.flowConditionImplies( AfterLoopEnv.makeNot(AfterLoopFooVal))); }); @@ -4243,7 +4191,7 @@ TEST(TransferTest, ForStmtBranchWithoutConditionDoesNotExtendFlowCondition) { ASSERT_THAT(FooDecl, NotNull()); BoolValue &LoopBodyFooVal = - *cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None)); + *cast(LoopBodyEnv.getValue(*FooDecl)); EXPECT_FALSE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal)); }); } @@ -4269,7 +4217,7 @@ TEST(TransferTest, ContextSensitiveOptionDisabled) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, @@ -4326,7 +4274,7 @@ TEST(TransferTest, ContextSensitiveDepthZero) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, @@ -4354,7 +4302,7 @@ TEST(TransferTest, ContextSensitiveSetTrue) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4381,7 +4329,7 @@ TEST(TransferTest, ContextSensitiveSetFalse) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4413,11 +4361,11 @@ TEST(TransferTest, ContextSensitiveSetBothTrueAndFalse) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); - auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }, @@ -4446,7 +4394,7 @@ TEST(TransferTest, ContextSensitiveSetTwoLayersDepthOne) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, @@ -4475,7 +4423,7 @@ TEST(TransferTest, ContextSensitiveSetTwoLayersDepthTwo) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/2}}}); @@ -4504,7 +4452,7 @@ TEST(TransferTest, ContextSensitiveSetThreeLayersDepthTwo) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, @@ -4534,7 +4482,7 @@ TEST(TransferTest, ContextSensitiveSetThreeLayersDepthThree) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/3}}}); @@ -4576,7 +4524,7 @@ TEST(TransferTest, ContextSensitiveMutualRecursion) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); // ... but it also can't prove anything here. EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); @@ -4611,11 +4559,11 @@ TEST(TransferTest, ContextSensitiveSetMultipleLines) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); - auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }, @@ -4653,11 +4601,11 @@ TEST(TransferTest, ContextSensitiveSetMultipleBlocks) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); - auto &BazVal = *cast(Env.getValue(*BazDecl, SkipPast::None)); + auto &BazVal = *cast(Env.getValue(*BazDecl)); EXPECT_TRUE(Env.flowConditionImplies(BazVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(BazVal))); }, @@ -4702,7 +4650,7 @@ TEST(TransferTest, ContextSensitiveReturnTrue) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4727,7 +4675,7 @@ TEST(TransferTest, ContextSensitiveReturnFalse) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4755,7 +4703,7 @@ TEST(TransferTest, ContextSensitiveReturnArg) { const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); - auto &BazVal = *cast(Env.getValue(*BazDecl, SkipPast::None)); + auto &BazVal = *cast(Env.getValue(*BazDecl)); EXPECT_TRUE(Env.flowConditionImplies(BazVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4803,7 +4751,7 @@ TEST(TransferTest, ContextSensitiveMethodLiteral) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4835,7 +4783,7 @@ TEST(TransferTest, ContextSensitiveMethodGetter) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4867,7 +4815,7 @@ TEST(TransferTest, ContextSensitiveMethodSetter) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4901,7 +4849,7 @@ TEST(TransferTest, ContextSensitiveMethodGetterAndSetter) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4936,7 +4884,7 @@ TEST(TransferTest, ContextSensitiveMethodTwoLayersVoid) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -4970,7 +4918,7 @@ TEST(TransferTest, ContextSensitiveMethodTwoLayersReturn) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -5001,7 +4949,7 @@ TEST(TransferTest, ContextSensitiveConstructorBody) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -5032,7 +4980,7 @@ TEST(TransferTest, ContextSensitiveConstructorInitializer) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); @@ -5063,7 +5011,7 @@ TEST(TransferTest, ContextSensitiveConstructorDefault) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); + auto &FooVal = *cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, {BuiltinOptions{ContextSensitiveOptions{}}}); diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp index 57ab1c652d602..a8b0c6bd6a087 100644 --- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp @@ -489,8 +489,7 @@ TEST_F(JoinFlowConditionsTest, JoinDistinctButProvablyEquivalentValues) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return cast( - Env.getValue(*FooDecl, SkipPast::None)->getProperty("is_set")); + return cast(Env.getValue(*FooDecl)->getProperty("is_set")); }; EXPECT_FALSE(Env1.flowConditionImplies(*GetFooValue(Env1))); @@ -640,7 +639,7 @@ TEST_F(WideningTest, JoinDistinctValuesWithDistinctProperties) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; EXPECT_EQ(GetFooValue(Env1)->getProperty("has_value"), @@ -685,7 +684,7 @@ TEST_F(WideningTest, JoinDistinctValuesWithSameProperties) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; EXPECT_EQ(GetFooValue(Env1)->getProperty("has_value"), @@ -725,8 +724,7 @@ TEST_F(WideningTest, DistinctPointersToTheSameLocationAreEquivalent) { const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarVal = - cast(Env.getValue(*BarDecl, SkipPast::None)); + const auto *BarVal = cast(Env.getValue(*BarDecl)); EXPECT_EQ(&BarVal->getPointeeLoc(), FooLoc); }); } @@ -755,7 +753,7 @@ TEST_F(WideningTest, DistinctValuesWithSamePropertiesAreEquivalent) { const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - const auto *FooVal = Env.getValue(*FooDecl, SkipPast::None); + const auto *FooVal = Env.getValue(*FooDecl); EXPECT_EQ(FooVal->getProperty("has_value"), &Env.getBoolLiteralValue(true)); }); @@ -804,13 +802,11 @@ TEST_F(FlowConditionTest, IfStmtSingleVar) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = - cast(Env1.getValue(*FooDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); EXPECT_TRUE(Env1.flowConditionImplies(*FooVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = - cast(Env2.getValue(*FooDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); EXPECT_FALSE(Env2.flowConditionImplies(*FooVal2)); }); } @@ -837,13 +833,11 @@ TEST_F(FlowConditionTest, IfStmtSingleNegatedVar) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = - cast(Env1.getValue(*FooDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); EXPECT_FALSE(Env1.flowConditionImplies(*FooVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = - cast(Env2.getValue(*FooDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); EXPECT_TRUE(Env2.flowConditionImplies(*FooVal2)); }); } @@ -867,7 +861,7 @@ TEST_F(FlowConditionTest, WhileStmt) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); - auto *FooVal = cast(Env.getValue(*FooDecl, SkipPast::None)); + auto *FooVal = cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(*FooVal)); }); } @@ -896,14 +890,14 @@ TEST_F(FlowConditionTest, Conjunction) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = cast(Env1.getValue(*FooDecl, SkipPast::None)); - auto *BarVal1 = cast(Env1.getValue(*BarDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); + auto *BarVal1 = cast(Env1.getValue(*BarDecl)); EXPECT_TRUE(Env1.flowConditionImplies(*FooVal1)); EXPECT_TRUE(Env1.flowConditionImplies(*BarVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = cast(Env2.getValue(*FooDecl, SkipPast::None)); - auto *BarVal2 = cast(Env2.getValue(*BarDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); + auto *BarVal2 = cast(Env2.getValue(*BarDecl)); EXPECT_FALSE(Env2.flowConditionImplies(*FooVal2)); EXPECT_FALSE(Env2.flowConditionImplies(*BarVal2)); }); @@ -933,14 +927,14 @@ TEST_F(FlowConditionTest, Disjunction) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = cast(Env1.getValue(*FooDecl, SkipPast::None)); - auto *BarVal1 = cast(Env1.getValue(*BarDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); + auto *BarVal1 = cast(Env1.getValue(*BarDecl)); EXPECT_FALSE(Env1.flowConditionImplies(*FooVal1)); EXPECT_FALSE(Env1.flowConditionImplies(*BarVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = cast(Env2.getValue(*FooDecl, SkipPast::None)); - auto *BarVal2 = cast(Env2.getValue(*BarDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); + auto *BarVal2 = cast(Env2.getValue(*BarDecl)); EXPECT_FALSE(Env2.flowConditionImplies(*FooVal2)); EXPECT_FALSE(Env2.flowConditionImplies(*BarVal2)); }); @@ -970,14 +964,14 @@ TEST_F(FlowConditionTest, NegatedConjunction) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = cast(Env1.getValue(*FooDecl, SkipPast::None)); - auto *BarVal1 = cast(Env1.getValue(*BarDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); + auto *BarVal1 = cast(Env1.getValue(*BarDecl)); EXPECT_FALSE(Env1.flowConditionImplies(*FooVal1)); EXPECT_FALSE(Env1.flowConditionImplies(*BarVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = cast(Env2.getValue(*FooDecl, SkipPast::None)); - auto *BarVal2 = cast(Env2.getValue(*BarDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); + auto *BarVal2 = cast(Env2.getValue(*BarDecl)); EXPECT_TRUE(Env2.flowConditionImplies(*FooVal2)); EXPECT_TRUE(Env2.flowConditionImplies(*BarVal2)); }); @@ -1007,14 +1001,14 @@ TEST_F(FlowConditionTest, DeMorgan) { ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2")); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto *FooVal1 = cast(Env1.getValue(*FooDecl, SkipPast::None)); - auto *BarVal1 = cast(Env1.getValue(*BarDecl, SkipPast::None)); + auto *FooVal1 = cast(Env1.getValue(*FooDecl)); + auto *BarVal1 = cast(Env1.getValue(*BarDecl)); EXPECT_TRUE(Env1.flowConditionImplies(*FooVal1)); EXPECT_TRUE(Env1.flowConditionImplies(*BarVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto *FooVal2 = cast(Env2.getValue(*FooDecl, SkipPast::None)); - auto *BarVal2 = cast(Env2.getValue(*BarDecl, SkipPast::None)); + auto *FooVal2 = cast(Env2.getValue(*FooDecl)); + auto *BarVal2 = cast(Env2.getValue(*BarDecl)); EXPECT_FALSE(Env2.flowConditionImplies(*FooVal2)); EXPECT_FALSE(Env2.flowConditionImplies(*BarVal2)); }); @@ -1044,7 +1038,7 @@ TEST_F(FlowConditionTest, Join) { ASSERT_THAT(FooDecl, NotNull()); const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); - auto *FooVal = cast(Env.getValue(*FooDecl, SkipPast::None)); + auto *FooVal = cast(Env.getValue(*FooDecl)); EXPECT_TRUE(Env.flowConditionImplies(*FooVal)); }); } @@ -1077,8 +1071,7 @@ TEST_F(FlowConditionTest, OpaqueFlowConditionMergesToOpaqueBool) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarVal = - *cast(Env.getValue(*BarDecl, SkipPast::Reference)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); }); @@ -1119,8 +1112,7 @@ TEST_F(FlowConditionTest, OpaqueFieldFlowConditionMergesToOpaqueBool) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarVal = - *cast(Env.getValue(*BarDecl, SkipPast::Reference)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); }); @@ -1154,8 +1146,7 @@ TEST_F(FlowConditionTest, OpaqueFlowConditionInsideBranchMergesToOpaqueBool) { const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto &BarVal = - *cast(Env.getValue(*BarDecl, SkipPast::Reference)); + auto &BarVal = *cast(Env.getValue(*BarDecl)); EXPECT_FALSE(Env.flowConditionImplies(BarVal)); }); @@ -1184,13 +1175,11 @@ TEST_F(FlowConditionTest, PointerToBoolImplicitCast) { ASSERT_THAT(FooDecl, NotNull()); const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1"); - auto &FooVal1 = - *cast(Env1.getValue(*FooDecl, SkipPast::Reference)); + auto &FooVal1 = *cast(Env1.getValue(*FooDecl)); EXPECT_TRUE(Env1.flowConditionImplies(FooVal1)); const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2"); - auto &FooVal2 = - *cast(Env2.getValue(*FooDecl, SkipPast::Reference)); + auto &FooVal2 = *cast(Env2.getValue(*FooDecl)); EXPECT_FALSE(Env2.flowConditionImplies(FooVal2)); }); } @@ -1267,9 +1256,8 @@ TEST_F(TopTest, UnusedTopInitializer) { const ValueDecl *FooDecl = findValueDecl(AO.ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal1 = GetFooValue(Env1); @@ -1313,9 +1301,8 @@ TEST_F(TopTest, UnusedTopAssignment) { const ValueDecl *FooDecl = findValueDecl(AO.ASTCtx, "Foo"); ASSERT_THAT(FooDecl, NotNull()); - auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal1 = GetFooValue(Env1); @@ -1366,7 +1353,7 @@ TEST_F(TopTest, UnusedTopJoinsToTop) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal1 = GetFooValue(Env1); @@ -1421,7 +1408,7 @@ TEST_F(TopTest, TopUsedBeforeBranchJoinsToSameAtomicBool) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal0 = GetFooValue(Env0); @@ -1477,7 +1464,7 @@ TEST_F(TopTest, TopUsedInBothBranchesJoinsToAtomic) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal1 = GetFooValue(Env1); @@ -1525,12 +1512,10 @@ TEST_F(TopTest, TopUsedInBothBranchesWithoutPrecisionLoss) { const ValueDecl *BarDecl = findValueDecl(AO.ASTCtx, "Bar"); ASSERT_THAT(BarDecl, NotNull()); - auto *FooVal = - dyn_cast_or_null(Env.getValue(*FooDecl, SkipPast::None)); + auto *FooVal = dyn_cast_or_null(Env.getValue(*FooDecl)); ASSERT_THAT(FooVal, NotNull()); - auto *BarVal = - dyn_cast_or_null(Env.getValue(*BarDecl, SkipPast::None)); + auto *BarVal = dyn_cast_or_null(Env.getValue(*BarDecl)); ASSERT_THAT(BarVal, NotNull()); EXPECT_TRUE(Env.flowConditionImplies(Env.makeIff(*FooVal, *BarVal))); @@ -1570,7 +1555,7 @@ TEST_F(TopTest, TopUnusedBeforeLoopHeadJoinsToTop) { ASSERT_THAT(FooDecl, NotNull()); auto GetFooValue = [FooDecl](const Environment &Env) { - return Env.getValue(*FooDecl, SkipPast::None); + return Env.getValue(*FooDecl); }; Value *FooVal1 = GetFooValue(Env1);