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 <[email protected]>
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,
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,
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits