[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 30 05:52:41 PST 2019


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/AST/Stmt.h:1259
+  // the index of the last one.
+  unsigned getLastNonNullStmt() const {
+    assert(!body_empty() && "getLastNonNullStmt");
----------------
How about `getIndexOfLastNonNullStmt()` since it doesn't return the `Stmt*` itself?


================
Comment at: clang/lib/CodeGen/CGStmt.cpp:385
 
-  for (CompoundStmt::const_body_iterator I = S.body_begin(),
-       E = S.body_end()-GetLast; I != E; ++I)
-    EmitStmt(*I);
-
+  Stmt *ExprResult = GetLast ? S.getStmtExprResult() : nullptr;
   Address RetAlloca = Address::invalid();
----------------
`const Stmt *`


================
Comment at: clang/lib/CodeGen/CGStmt.cpp:390
+      E = S.body_end(); I != E; ++I) {
+    if (GetLast && ExprResult == *I) {
+      // We have to special case labels here.  They are statements, but when put
----------------
What happens if `ExprResult` is `nullptr`?


================
Comment at: clang/test/CodeGen/exprs.c:202
+int f19() {
+  return ({ 3;;4;; });
+}
----------------
Does this test need the extra null statement between the `3;` and `4;`?


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

https://reviews.llvm.org/D57086





More information about the cfe-commits mailing list