[PATCH] D125936: [Sema] Relax an assertion in BuildStmtExpr

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 10:49:55 PDT 2022


ahatanak added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:15746
 ExprResult Sema::BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
                                SourceLocation RPLoc, unsigned TemplateDepth) {
   assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
----------------
rsmith wrote:
> Is it possible to pass a flag into here to indicate if we're really building an `asm` statement? I don't think we want to remove the assert for a user-written statement expression that happens to begin with an `asm` statement.
> 
> It's ironic that we're building a statement expression to wrap an `asm` statement in order to make sure that cleanups are handled properly, and the `StmtExpr` is asserting because it doesn't expect to need to handle cleanups...
Maybe we can add a flag to `StmtExpr` and set it in `Sema::MaybeCreateStmtWithCleanups` to distinguish `StmtExpr`s that are created for gnu statement expressions from those that aren't?

If we don't want to use `StmtExpr` for asm statements, maybe we have to create a new `Stmt` type just for that purpose as suggested in `Sema::MaybeCreateStmtWithCleanups`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125936/new/

https://reviews.llvm.org/D125936



More information about the cfe-commits mailing list