kinu updated this revision to Diff 518676. kinu added a comment. Add a while-true test
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149640/new/ https://reviews.llvm.org/D149640 Files: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp clang/unittests/Analysis/FlowSensitive/TransferTest.cpp Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp =================================================================== --- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -5271,4 +5271,22 @@ }); } +TEST(TransferTest, UnreachedAfterWhileTrue) { + // PruneTriviallyFalseEdges should have pruned the unreached node. + std::string Code = R"( + void target() { + while (true) {} + (void)0; + /*[[p]]*/ + } + )"; + runDataflow( + Code, + [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results, + ASTContext &ASTCtx) { + ASSERT_TRUE(Results.empty()); + }); +} + + } // namespace Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp =================================================================== --- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp +++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp @@ -70,7 +70,7 @@ llvm::Expected<ControlFlowContext> ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) { CFG::BuildOptions Options; - Options.PruneTriviallyFalseEdges = false; + Options.PruneTriviallyFalseEdges = true; Options.AddImplicitDtors = true; Options.AddTemporaryDtors = true; Options.AddInitializers = true;
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp =================================================================== --- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -5271,4 +5271,22 @@ }); } +TEST(TransferTest, UnreachedAfterWhileTrue) { + // PruneTriviallyFalseEdges should have pruned the unreached node. + std::string Code = R"( + void target() { + while (true) {} + (void)0; + /*[[p]]*/ + } + )"; + runDataflow( + Code, + [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results, + ASTContext &ASTCtx) { + ASSERT_TRUE(Results.empty()); + }); +} + + } // namespace Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp =================================================================== --- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp +++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp @@ -70,7 +70,7 @@ llvm::Expected<ControlFlowContext> ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) { CFG::BuildOptions Options; - Options.PruneTriviallyFalseEdges = false; + Options.PruneTriviallyFalseEdges = true; Options.AddImplicitDtors = true; Options.AddTemporaryDtors = true; Options.AddInitializers = true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits