[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 3 11:42:27 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG791b0fd02668: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG (authored by kinu, committed by mboehme).
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
@@ -2644,7 +2644,7 @@
void target(int *Foo) {
do {
int Bar = *Foo;
- } while (true);
+ } while (false);
(void)0;
/*[[p]]*/
}
@@ -2675,6 +2675,24 @@
});
}
+TEST(TransferTest, UnreachableAfterWhileTrue) {
+ std::string Code = R"(
+ void target() {
+ while (true) {}
+ (void)0;
+ /*[[p]]*/
+ }
+ )";
+ runDataflow(
+ Code,
+ [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
+ ASTContext &ASTCtx) {
+ // The node after the while-true is pruned because it is trivially
+ // known to be unreachable.
+ ASSERT_TRUE(Results.empty());
+ });
+}
+
TEST(TransferTest, AggregateInitialization) {
std::string BracesCode = R"(
struct A {
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149640.519189.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230503/7462d87a/attachment-0001.bin>
More information about the cfe-commits
mailing list