Skip to content

[clang][analysis] Fix flaky clang/test/Analysis/live-stmts.cpp test (2nd attempt) (#127406) #139591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions clang/lib/Analysis/LiveVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,19 @@ void LiveVariables::dumpExprLiveness(const SourceManager &M) {
}

void LiveVariablesImpl::dumpExprLiveness(const SourceManager &M) {
const ASTContext &Ctx = analysisContext.getASTContext();
auto ByIDs = [&Ctx](const Expr *L, const Expr *R) {
return L->getID(Ctx) < R->getID(Ctx);
};

// Don't iterate over blockEndsToLiveness directly because it's not sorted.
for (const CFGBlock *B : *analysisContext.getCFG()) {

llvm::errs() << "\n[ B" << B->getBlockID()
<< " (live expressions at block exit) ]\n";
for (const Expr *E : blocksEndToLiveness[B].liveExprs) {
std::vector<const Expr *> LiveExprs;
llvm::append_range(LiveExprs, blocksEndToLiveness[B].liveExprs);
llvm::sort(LiveExprs, ByIDs);
for (const Expr *E : LiveExprs) {
llvm::errs() << "\n";
E->dump();
}
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Analysis/live-stmts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ int testThatDumperWorks(int x, int y, int z) {
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
// CHECK-EMPTY:
// CHECK-EMPTY:
// CHECK: [ B4 (live expressions at block exit) ]
// CHECK-EMPTY:
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
Expand Down
Loading