[PATCH] D112050: [clang] NFC: return void in an alternative expression after call to void function.

zhouyizhou via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 19:29:39 PDT 2021


zhouyizhou created this revision.
zhouyizhou added a reviewer: clang.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is better to return void in an alternative expression after call to void function. Also, I processed emitDestroy's function body using clang-format.

I don't have write access to LLVM repository,  if the patch got approved, can someone commit for me ?

Thanks 
Zhouyi

Signed-off-by: Zhouyi Zhou <zhouzhouyi at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112050

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===================================================================
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2181,14 +2181,15 @@
                                   Destroyer *destroyer,
                                   bool useEHCleanupForArray) {
   const ArrayType *arrayType = getContext().getAsArrayType(type);
-  if (!arrayType)
-    return destroyer(*this, addr, type);
+  if (!arrayType) {
+    destroyer(*this, addr, type);
+    return;
+  }
 
   llvm::Value *length = emitArrayLength(arrayType, type, addr);
 
-  CharUnits elementAlign =
-    addr.getAlignment()
-        .alignmentOfArrayElement(getContext().getTypeSizeInChars(type));
+  CharUnits elementAlign = addr.getAlignment().alignmentOfArrayElement(
+      getContext().getTypeSizeInChars(type));
 
   // Normally we have to check whether the array is zero-length.
   bool checkZeroLength = true;
@@ -2196,15 +2197,16 @@
   // But if the array length is constant, we can suppress that.
   if (llvm::ConstantInt *constLength = dyn_cast<llvm::ConstantInt>(length)) {
     // ...and if it's constant zero, we can just skip the entire thing.
-    if (constLength->isZero()) return;
+    if (constLength->isZero())
+      return;
     checkZeroLength = false;
   }
 
   llvm::Value *begin = addr.getPointer();
   llvm::Value *end =
       Builder.CreateInBoundsGEP(addr.getElementType(), begin, length);
-  emitArrayDestroy(begin, end, type, elementAlign, destroyer,
-                   checkZeroLength, useEHCleanupForArray);
+  emitArrayDestroy(begin, end, type, elementAlign, destroyer, checkZeroLength,
+                   useEHCleanupForArray);
 }
 
 /// emitArrayDestroy - Destroys all the elements of the given array,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112050.380568.patch
Type: text/x-patch
Size: 1756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211019/6c88ed38/attachment-0001.bin>


More information about the cfe-commits mailing list