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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 5 07:49:06 PST 2019


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/AST/Stmt.h:1259-1260
+  // This gets the index of the last Stmt before the trailing NullStmts. If
+  // this compound expression contains nothing but NullStmts, then we return
+  // the index of the last one. If the compound statement is empty, return
+  // None.
----------------
Given the name of the function, why return the index of the last null statement if it only contains null statements? 


================
Comment at: clang/include/clang/AST/Stmt.h:1270
+    }
+    return size() - 1;
+  }
----------------
The only way you can get here is if all statements are null statements, so this should return `None` as well, shouldn't it?


================
Comment at: clang/include/clang/AST/Stmt.h:1315-1316
+    Optional<unsigned> ExprResult = getIndexOfLastNonNullStmt();
+    return ExprResult.hasValue() ? body_begin()[ExprResult.getValue()]
+                                 : nullptr;
   }
----------------
`return ExprResult ? body_begin()[*ExprResult] : nullptr;`


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

https://reviews.llvm.org/D57086





More information about the cfe-commits mailing list