[PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 17:59:45 PDT 2016


rsmith added inline comments.

================
Comment at: lib/Sema/SemaType.cpp:1253-1254
@@ -1252,4 +1253,4 @@
       break;
     } else if (declarator.getContext() == Declarator::LambdaExprContext ||
                isOmittedBlockReturnType(declarator)) {
       Result = Context.DependentTy;
----------------
Instead of checking for qualifiers below, how about checking here (or, preferably, in `isOmittedBlockReturnType`) whether there were any present, and not treating the block as having an omitted return type if there actually is a return type present?

================
Comment at: lib/Sema/SemaType.cpp:1561
@@ +1560,3 @@
+    AttributeList *cur = attrs, *prev = nullptr;
+    while (cur) {
+      AttributeList &attr = *cur;
----------------
Maybe write this as `for (AttributeList *cur = attrs; cur; cur = cur->getNext())` and drop the `cur = cur->getNext()` assignments below.

================
Comment at: lib/Sema/SemaType.cpp:1575-1583
@@ +1574,11 @@
+      // Remove cur from the list.
+      if (attrs == cur) {
+        attrs = attr.getNext();
+        prev = nullptr;
+        cur = cur->getNext();
+        continue;
+      }
+      prev->setNext(attr.getNext());
+      prev = cur;
+      cur = cur->getNext();
+    }
----------------
You can express this more simply as:

  if (prev)
    prev->setNext(cur->getNext());
  else
    attrs = cur->getNext();
  cur = cur->getNext();



http://reviews.llvm.org/D18567





More information about the cfe-commits mailing list