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

Dominic Ferreira via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 30 17:01:59 PST 2019


domdom updated this revision to Diff 184413.
domdom marked 6 inline comments as done.

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

https://reviews.llvm.org/D57086

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/CodeGen/CGStmt.cpp


Index: clang/lib/CodeGen/CGStmt.cpp
===================================================================
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -382,7 +382,7 @@
                                               bool GetLast,
                                               AggValueSlot AggSlot) {
 
-  Stmt *ExprResult = GetLast ? S.getStmtExprResult() : nullptr;
+  const Stmt *ExprResult = GetLast ? S.getStmtExprResult() : nullptr;
   Address RetAlloca = Address::invalid();
 
   for (CompoundStmt::const_body_iterator I = S.body_begin(), E = S.body_end();
Index: clang/include/clang/AST/Stmt.h
===================================================================
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -1256,8 +1256,8 @@
   // 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.
-  unsigned getLastNonNullStmt() const {
-    assert(!body_empty() && "getLastNonNullStmt");
+  unsigned getIndexOfLastNonNullStmt() const {
+    assert(!body_empty() && "getIndexOfLastNonNullStmt");
     for (unsigned I = size(), E = 0; I != E; I--) {
       if (!isa<NullStmt>(body_begin()[I - 1]))
         return I - 1;
@@ -1298,7 +1298,7 @@
   // another Stmt.
   void setStmtExpr(Stmt *S) {
     assert(!body_empty() && "setStmtExpr");
-    unsigned ExprResult = getLastNonNullStmt();
+    unsigned ExprResult = getIndexOfLastNonNullStmt();
     assert(!isa<NullStmt>(body_begin()[ExprResult])
         && "setStmtExpr but there is no non-NullStmt");
     body_begin()[ExprResult] = S;
@@ -1306,7 +1306,7 @@
 
   // Get the Stmt representing the result of this compound expression.
   Stmt *getStmtExprResult() const {
-    unsigned ExprResult = getLastNonNullStmt();
+    unsigned ExprResult = getIndexOfLastNonNullStmt();
     return body_begin()[ExprResult];
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57086.184413.patch
Type: text/x-patch
Size: 1946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190131/7a48eeb0/attachment.bin>


More information about the cfe-commits mailing list