[PATCH] D127236: [clang][pr55896]:co_yield/co_await thread-safety
Nathan Sidwell via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 04:42:31 PDT 2022
This revision was automatically updated to reflect the committed changes.
urnathan marked an inline comment as done.
Closed by commit rG65b34b78f8da: [clang][pr55896]:co_yield/co_await thread-safety (authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D127236?vs=434887&id=435501#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127236/new/
https://reviews.llvm.org/D127236
Files:
clang/lib/Analysis/CFG.cpp
clang/test/SemaCXX/thread-safety-coro.cpp
Index: clang/test/SemaCXX/thread-safety-coro.cpp
===================================================================
--- clang/test/SemaCXX/thread-safety-coro.cpp
+++ clang/test/SemaCXX/thread-safety-coro.cpp
@@ -38,10 +38,14 @@
Task get_return_object() noexcept;
void unhandled_exception() noexcept;
void return_value(int value) noexcept;
+
+ std::suspend_always yield_value(int value) noexcept;
};
};
Task Foo() noexcept {
// ICE'd
+ co_yield({ int frame = 0; 0; });
+ co_await({ int frame = 0; std::suspend_always(); });
co_return({ int frame = 0; 0; });
}
Index: clang/lib/Analysis/CFG.cpp
===================================================================
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -597,6 +597,8 @@
CFGBlock *VisitObjCMessageExpr(ObjCMessageExpr *E, AddStmtChoice asc);
CFGBlock *VisitPseudoObjectExpr(PseudoObjectExpr *E);
CFGBlock *VisitReturnStmt(Stmt *S);
+ CFGBlock *VisitCoroutineSuspendExpr(CoroutineSuspendExpr *S,
+ AddStmtChoice asc);
CFGBlock *VisitSEHExceptStmt(SEHExceptStmt *S);
CFGBlock *VisitSEHFinallyStmt(SEHFinallyStmt *S);
CFGBlock *VisitSEHLeaveStmt(SEHLeaveStmt *S);
@@ -2297,6 +2299,10 @@
case Stmt::CoreturnStmtClass:
return VisitReturnStmt(S);
+ case Stmt::CoyieldExprClass:
+ case Stmt::CoawaitExprClass:
+ return VisitCoroutineSuspendExpr(cast<CoroutineSuspendExpr>(S), asc);
+
case Stmt::SEHExceptStmtClass:
return VisitSEHExceptStmt(cast<SEHExceptStmt>(S));
@@ -3152,6 +3158,27 @@
return B;
}
+CFGBlock *CFGBuilder::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E,
+ AddStmtChoice asc) {
+ // We're modelling the pre-coro-xform CFG. Thus just evalate the various
+ // active components of the co_await or co_yield. Note we do not model the
+ // edge from the builtin_suspend to the exit node.
+ if (asc.alwaysAdd(*this, E)) {
+ autoCreateBlock();
+ appendStmt(Block, E);
+ }
+ CFGBlock *B = Block;
+ if (auto *R = Visit(E->getResumeExpr()))
+ B = R;
+ if (auto *R = Visit(E->getSuspendExpr()))
+ B = R;
+ if (auto *R = Visit(E->getReadyExpr()))
+ B = R;
+ if (auto *R = Visit(E->getCommonExpr()))
+ B = R;
+ return B;
+}
+
CFGBlock *CFGBuilder::VisitSEHExceptStmt(SEHExceptStmt *ES) {
// SEHExceptStmt are treated like labels, so they are the first statement in a
// block.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127236.435501.patch
Type: text/x-patch
Size: 2468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220609/265cc4f5/attachment.bin>
More information about the cfe-commits
mailing list