diff options
author | Kinuko Yasuda <kinuko@google.com> | 2023-05-03 11:37:44 +0000 |
---|---|---|
committer | Martin Braenne <mboehme@google.com> | 2023-05-03 18:42:15 +0000 |
commit | 791b0fd02668fd0fcf07788d4e16bb468434f4bf (patch) | |
tree | 5e70eede953a854ed40633d6a83443e242b7546d /clang/unittests | |
parent | 8b8466fd31e5a194fd8ba7a73a0f23d32f164318 (diff) | |
download | llvm-791b0fd02668fd0fcf07788d4e16bb468434f4bf.tar.gz |
[clang][dataflow] Change PruneTriviallyFalseEdges for building CFG
Keeping this false could end up with extra iterations on a lot of loops
that aren't real ones (e.g. they could be a do-while-false for macros),
and makes the analyses very slow.
This patch changes the default for
CFG::BuildOptions.PruneTriviallyFalseEdges to true to avoid it.
Reviewed By: ymandel, xazax.hun, gribozavr2
Differential Revision: https://reviews.llvm.org/D149640
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Analysis/FlowSensitive/TransferTest.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index 750d095af451..c8161c8f40fc 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -2644,7 +2644,7 @@ TEST(TransferTest, VarDeclInDoWhile) { void target(int *Foo) { do { int Bar = *Foo; - } while (true); + } while (false); (void)0; /*[[p]]*/ } @@ -2675,6 +2675,24 @@ TEST(TransferTest, VarDeclInDoWhile) { }); } +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 { |