[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 30 15:26:33 PDT 2018
rjmccall added inline comments.
================
Comment at: lib/CodeGen/CGExprConstant.cpp:1395
+static bool isZeroInitializer(ConstantEmitter &CE, const Expr *Init) {
+ QualType InitTy = Init->getType().getCanonicalType();
----------------
You should have a comment here clarifying that this is checking whether the initializer is equivalent to a C++ zero initialization, not checking whether the initializer produces a zero bit-pattern.
================
Comment at: lib/CodeGen/CGExprConstant.cpp:1414
+ return true;
+ }
+ }
----------------
You should check the array fill expression here; for now, the test case would be something like `StructWithNonTrivialDefaultInit sArr[10] = {};`.
================
Comment at: lib/CodeGen/CGExprConstant.cpp:1415
+ }
+ }
+ return false;
----------------
I would suggest doing your primary switch over the form of Init instead of its type, and you can just have an isIntegerConstantExpr check at the end.
You should also check for a null pointer expression.
Repository:
rC Clang
https://reviews.llvm.org/D46241
More information about the cfe-commits
mailing list