diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h @@ -82,9 +82,11 @@ /// Deprecated. Use the `DataflowAnalysisOptions` constructor instead. explicit DataflowAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer) - : DataflowAnalysis(Context, {ApplyBuiltinTransfer - ? TransferOptions{} - : llvm::Optional()}) {} + : DataflowAnalysis( + Context, + {ApplyBuiltinTransfer + ? DataflowAnalysisContext::Options{} + : llvm::Optional()}) {} explicit DataflowAnalysis(ASTContext &Context, DataflowAnalysisOptions Options) diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h @@ -50,13 +50,22 @@ /// Returns the set of all fields in the type. llvm::DenseSet getObjectFields(QualType Type); +struct ContextSensitiveOptions { + /// The maximum depth to analyze. A value of zero is equivalent to disabling + /// context-sensitive analysis entirely. + unsigned Depth = 2; +}; + /// Owns objects that encompass the state of a program and stores context that /// is used during dataflow analysis. class DataflowAnalysisContext { public: - // FIXME: merge with TransferOptions from Transfer.h. struct Options { - bool EnableContextSensitiveAnalysis; + /// Options for analyzing function bodies when present in the translation + /// unit, or empty to disable context-sensitive analysis. Note that this is + /// fundamentally limited: some constructs, such as recursion, are + /// explicitly unsupported. + llvm::Optional ContextSensitiveOpts; }; /// Constructs a dataflow analysis context. @@ -65,10 +74,10 @@ /// /// `S` must not be null. DataflowAnalysisContext(std::unique_ptr S, - Options Opts = { - /*EnableContextSensitiveAnalysis=*/false}) + Options Opts = Options{ + /*ContextSensitiveOpts=*/std::nullopt}) : S(std::move(S)), TrueVal(createAtomicBoolValue()), - FalseVal(createAtomicBoolValue()), Options(Opts) { + FalseVal(createAtomicBoolValue()), Opts(Opts) { assert(this->S != nullptr); } @@ -266,6 +275,8 @@ void addFieldsReferencedInScope(llvm::DenseSet Fields); + const Options &getOptions() { return Opts; } + private: struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo { static QualType getEmptyKey() { @@ -343,7 +354,7 @@ AtomicBoolValue &TrueVal; AtomicBoolValue &FalseVal; - Options Options; + Options Opts; // Indices that are used to avoid recreating the same composite boolean // values. 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 @@ -177,6 +177,10 @@ /// with a symbolic representation of the `this` pointee. Environment(DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx); + const DataflowAnalysisContext::Options &getAnalysisOptions() { + return DACtx->getOptions(); + } + /// Creates and returns an environment to use for an inline analysis of the /// callee. Uses the storage location from each argument in the `Call` as the /// storage location for the corresponding parameter in the callee. diff --git a/clang/include/clang/Analysis/FlowSensitive/Transfer.h b/clang/include/clang/Analysis/FlowSensitive/Transfer.h --- a/clang/include/clang/Analysis/FlowSensitive/Transfer.h +++ b/clang/include/clang/Analysis/FlowSensitive/Transfer.h @@ -15,26 +15,12 @@ #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H #include "clang/AST/Stmt.h" +#include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" -#include "llvm/ADT/Optional.h" namespace clang { namespace dataflow { -struct ContextSensitiveOptions { - /// The maximum depth to analyze. A value of zero is equivalent to disabling - /// context-sensitive analysis entirely. - unsigned Depth = 2; -}; - -struct TransferOptions { - /// Options for analyzing function bodies when present in the translation - /// unit, or empty to disable context-sensitive analysis. Note that this is - /// fundamentally limited: some constructs, such as recursion, are explicitly - /// unsupported. - llvm::Optional ContextSensitiveOpts; -}; - /// Maps statements to the environments of basic blocks that contain them. class StmtToEnvMap { public: @@ -51,8 +37,7 @@ /// Requirements: /// /// `S` must not be `ParenExpr` or `ExprWithCleanups`. -void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env, - TransferOptions Options); +void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env); } // namespace dataflow } // namespace clang diff --git a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h @@ -21,9 +21,9 @@ #include "clang/AST/Stmt.h" #include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/ControlFlowContext.h" +#include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" -#include "clang/Analysis/FlowSensitive/Transfer.h" #include "llvm/ADT/Any.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/Error.h" @@ -32,11 +32,12 @@ namespace dataflow { struct DataflowAnalysisOptions { - /// Options for the built-in transfer functions, or empty to not apply them. + /// Options for the built-in model, or empty to not apply them. // FIXME: Remove this option once the framework supports composing analyses // (at which point the built-in transfer functions can be simply a standalone // analysis). - llvm::Optional BuiltinTransferOpts = TransferOptions{}; + llvm::Optional BuiltinOpts = + DataflowAnalysisContext::Options{}; }; /// Type-erased lattice element container. @@ -106,11 +107,11 @@ virtual void transferBranchTypeErased(bool Branch, const Stmt *, TypeErasedLattice &, Environment &) = 0; - /// If the built-in transfer functions (which model the heap and stack in the - /// `Environment`) are to be applied, returns the options to be passed to + /// If the built-in model is enabled, returns the options to be passed to /// them. Otherwise returns empty. - llvm::Optional builtinTransferOptions() const { - return Options.BuiltinTransferOpts; + const llvm::Optional & + builtinOptions() const { + return Options.BuiltinOpts; } }; diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -48,9 +48,8 @@ // context-sensitive analysis. But, this only applies to storage locations, // since fields access it not allowed to fail. In contrast, field *values* // don't need this allowance, since the API allows for uninitialized fields. - auto Fields = Options.EnableContextSensitiveAnalysis - ? getObjectFields(Type) - : getReferencedFields(Type); + auto Fields = Opts.ContextSensitiveOpts ? getObjectFields(Type) + : getReferencedFields(Type); for (const FieldDecl *Field : Fields) FieldLocs.insert({Field, &createStorageLocation(Field->getType())}); return takeOwnership( 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 @@ -128,9 +128,8 @@ class TransferVisitor : public ConstStmtVisitor { public: - TransferVisitor(const StmtToEnvMap &StmtToEnv, Environment &Env, - TransferOptions Options) - : StmtToEnv(StmtToEnv), Env(Env), Options(Options) {} + TransferVisitor(const StmtToEnvMap &StmtToEnv, Environment &Env) + : StmtToEnv(StmtToEnv), Env(Env) {} void VisitBinaryOperator(const BinaryOperator *S) { const Expr *LHS = S->getLHS(); @@ -429,7 +428,7 @@ } void VisitReturnStmt(const ReturnStmt *S) { - if (!Options.ContextSensitiveOpts) + if (!Env.getAnalysisOptions().ContextSensitiveOpts) return; auto *Ret = S->getRetValue(); @@ -764,6 +763,7 @@ // `F` of `S`. The type `E` must be either `CallExpr` or `CXXConstructExpr`. template void transferInlineCall(const E *S, const FunctionDecl *F) { + const auto &Options = Env.getAnalysisOptions(); if (!(Options.ContextSensitiveOpts && Env.canDescend(Options.ContextSensitiveOpts->Depth, F))) return; @@ -808,12 +808,10 @@ const StmtToEnvMap &StmtToEnv; Environment &Env; - TransferOptions Options; }; -void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env, - TransferOptions Options) { - TransferVisitor(StmtToEnv, Env, Options).Visit(&S); +void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env) { + TransferVisitor(StmtToEnv, Env).Visit(&S); } } // namespace dataflow diff --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp --- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp +++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp @@ -95,9 +95,8 @@ : public ConstStmtVisitor { public: TerminatorVisitor(const StmtToEnvMap &StmtToEnv, Environment &Env, - int BlockSuccIdx, TransferOptions TransferOpts) - : StmtToEnv(StmtToEnv), Env(Env), - BlockSuccIdx(BlockSuccIdx), TransferOpts(TransferOpts) {} + int BlockSuccIdx) + : StmtToEnv(StmtToEnv), Env(Env), BlockSuccIdx(BlockSuccIdx) {} TerminatorVisitorRetTy VisitIfStmt(const IfStmt *S) { auto *Cond = S->getCond(); @@ -142,7 +141,7 @@ TerminatorVisitorRetTy extendFlowCondition(const Expr &Cond) { // The terminator sub-expression might not be evaluated. if (Env.getStorageLocation(Cond, SkipPast::None) == nullptr) - transfer(StmtToEnv, Cond, Env, TransferOpts); + transfer(StmtToEnv, Cond, Env); // FIXME: The flow condition must be an r-value, so `SkipPast::None` should // suffice. @@ -178,7 +177,6 @@ const StmtToEnvMap &StmtToEnv; Environment &Env; int BlockSuccIdx; - TransferOptions TransferOpts; }; /// Holds data structures required for running dataflow analysis. @@ -248,8 +246,6 @@ llvm::Optional MaybeState; auto &Analysis = AC.Analysis; - auto BuiltinTransferOpts = Analysis.builtinTransferOptions(); - for (const CFGBlock *Pred : Preds) { // Skip if the `Block` is unreachable or control flow cannot get past it. if (!Pred || Pred->hasNoReturnElement()) @@ -263,13 +259,12 @@ continue; TypeErasedDataflowAnalysisState PredState = *MaybePredState; - if (BuiltinTransferOpts) { + if (Analysis.builtinOptions()) { if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) { const StmtToEnvMapImpl StmtToEnv(AC.CFCtx, AC.BlockStates); auto [Cond, CondValue] = TerminatorVisitor(StmtToEnv, PredState.Env, - blockIndexInPredecessor(*Pred, Block), - *BuiltinTransferOpts) + blockIndexInPredecessor(*Pred, Block)) .Visit(PredTerminatorStmt); if (Cond != nullptr) // FIXME: Call transferBranchTypeErased even if BuiltinTransferOpts @@ -301,8 +296,7 @@ AnalysisContext &AC) { const Stmt *S = Elt.getStmt(); assert(S != nullptr); - transfer(StmtToEnvMapImpl(AC.CFCtx, AC.BlockStates), *S, InputState.Env, - *AC.Analysis.builtinTransferOptions()); + transfer(StmtToEnvMapImpl(AC.CFCtx, AC.BlockStates), *S, InputState.Env); } /// Built-in transfer function for `CFGInitializer`. @@ -373,7 +367,7 @@ auto State = computeBlockInputState(Block, AC); for (const auto &Element : Block) { // Built-in analysis - if (AC.Analysis.builtinTransferOptions()) { + if (AC.Analysis.builtinOptions()) { builtinTransfer(Element, State, AC); } diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h +++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h @@ -29,6 +29,7 @@ #include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/ControlFlowContext.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/MatchSwitch.h" #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h" @@ -135,8 +136,8 @@ return std::move(*this); } AnalysisInputs && - withContextSensitivity() && { - EnableContextSensitivity = true; + withBuiltinOptions(DataflowAnalysisContext::Options Options) && { + BuiltinOptions = std::move(Options); return std::move(*this); } @@ -164,9 +165,8 @@ ArrayRef ASTBuildArgs = {}; /// Optional. Options for building the AST context. tooling::FileContentMappings ASTBuildVirtualMappedFiles = {}; - /// Enables context-sensitive analysis when constructing the - /// `DataflowAnalysisContext`. - bool EnableContextSensitivity = false; + /// Configuration options for the built-in model. + DataflowAnalysisContext::Options BuiltinOptions; }; /// Returns assertions based on annotations that are present after statements in @@ -230,9 +230,8 @@ auto &CFCtx = *MaybeCFCtx; // Initialize states for running dataflow analysis. - DataflowAnalysisContext DACtx( - std::make_unique(), - {/*EnableContextSensitiveAnalysis=*/AI.EnableContextSensitivity}); + DataflowAnalysisContext DACtx(std::make_unique(), + {/*Opts=*/AI.BuiltinOptions}); Environment InitEnv(DACtx, *Target); auto Analysis = AI.MakeAnalysis(Context, InitEnv); std::function void runDataflow(llvm::StringRef Code, Matcher Match, DataflowAnalysisOptions Options, @@ -45,14 +48,18 @@ "-std=" + std::string(LangStandard::getLangStandardForKind(Std).getName())}; auto AI = - AnalysisInputs(Code, hasName(TargetFun), - [&Options](ASTContext &C, Environment &) { - return NoopAnalysis(C, Options); - }) + AnalysisInputs( + Code, hasName(TargetFun), + [UseBuiltinModel = Options.BuiltinOpts.has_value()]( + ASTContext &C, Environment &Env) { + return NoopAnalysis(C, DataflowAnalysisOptions{ + UseBuiltinModel + ? Env.getAnalysisOptions() + : llvm::Optional()}); + }) .withASTBuildArgs(ASTBuildArgs); - if (Options.BuiltinTransferOpts && - Options.BuiltinTransferOpts->ContextSensitiveOpts) - AI = std::move(AI).withContextSensitivity(); + if (Options.BuiltinOpts) + AI = std::move(AI).withBuiltinOptions(*Options.BuiltinOpts); ASSERT_THAT_ERROR( checkDataflow( std::move(AI), @@ -69,8 +76,8 @@ bool ApplyBuiltinTransfer = true, llvm::StringRef TargetFun = "target") { runDataflow(Code, std::move(Match), - {ApplyBuiltinTransfer ? TransferOptions{} - : llvm::Optional()}, + {ApplyBuiltinTransfer ? BuiltinOptions{} + : llvm::Optional()}, Std, TargetFun); } @@ -4053,7 +4060,7 @@ EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{/*.ContextSensitiveOpts=*/std::nullopt}}); + {BuiltinOptions{/*.ContextSensitiveOpts=*/std::nullopt}}); } // This test is a regression test, based on a real crash. @@ -4082,7 +4089,7 @@ EXPECT_THAT(Env.getValue(*Loc), IsNull()); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveDepthZero) { @@ -4110,7 +4117,7 @@ EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/0}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/0}}}); } TEST(TransferTest, ContextSensitiveSetTrue) { @@ -4137,7 +4144,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveSetFalse) { @@ -4164,7 +4171,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveSetBothTrueAndFalse) { @@ -4201,7 +4208,7 @@ EXPECT_FALSE(Env.flowConditionImplies(BarVal)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveSetTwoLayersDepthOne) { @@ -4230,7 +4237,7 @@ EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/1}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/1}}}); } TEST(TransferTest, ContextSensitiveSetTwoLayersDepthTwo) { @@ -4258,7 +4265,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/2}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/2}}}); } TEST(TransferTest, ContextSensitiveSetThreeLayersDepthTwo) { @@ -4288,7 +4295,7 @@ EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/2}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/2}}}); } TEST(TransferTest, ContextSensitiveSetThreeLayersDepthThree) { @@ -4317,7 +4324,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/3}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/3}}}); } TEST(TransferTest, ContextSensitiveMutualRecursion) { @@ -4361,7 +4368,7 @@ EXPECT_FALSE(Env.flowConditionImplies(FooVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{/*.Depth=*/4}}}); + {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/4}}}); } TEST(TransferTest, ContextSensitiveSetMultipleLines) { @@ -4399,7 +4406,7 @@ EXPECT_FALSE(Env.flowConditionImplies(BarVal)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal))); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveSetMultipleBlocks) { @@ -4441,7 +4448,7 @@ EXPECT_TRUE(Env.flowConditionImplies(BazVal)); EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(BazVal))); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveReturnVoid) { @@ -4460,7 +4467,7 @@ ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); // This just tests that the analysis doesn't crash. }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveReturnTrue) { @@ -4485,7 +4492,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveReturnFalse) { @@ -4510,7 +4517,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal))); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveReturnArg) { @@ -4538,7 +4545,7 @@ auto &BazVal = *cast(Env.getValue(*BazDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(BazVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveReturnInt) { @@ -4557,7 +4564,7 @@ ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); // This just tests that the analysis doesn't crash. }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveMethodLiteral) { @@ -4586,7 +4593,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveMethodGetter) { @@ -4618,7 +4625,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveMethodSetter) { @@ -4650,7 +4657,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveMethodGetterAndSetter) { @@ -4684,7 +4691,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } @@ -4709,7 +4716,8 @@ Code, [](const llvm::StringMap> &Results, ASTContext &ASTCtx) { - ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));; + ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); + ; const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); @@ -4718,7 +4726,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveMethodTwoLayersReturn) { @@ -4742,7 +4750,8 @@ Code, [](const llvm::StringMap> &Results, ASTContext &ASTCtx) { - ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));; + ASSERT_THAT(Results.keys(), UnorderedElementsAre("p")); + ; const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo"); @@ -4751,7 +4760,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveConstructorBody) { @@ -4782,7 +4791,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveConstructorInitializer) { @@ -4813,7 +4822,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } TEST(TransferTest, ContextSensitiveConstructorDefault) { @@ -4844,7 +4853,7 @@ auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None)); EXPECT_TRUE(Env.flowConditionImplies(FooVal)); }, - {TransferOptions{ContextSensitiveOptions{}}}); + {BuiltinOptions{ContextSensitiveOptions{}}}); } } // namespace