[PATCH] D155580: [trivial-auto-var-init] Do not emit initialization code for empty class
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 18 10:42:34 PDT 2023
nickdesaulniers added inline comments.
================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1858
+static bool isEmptyClass(VarDecl const &D) {
+ const Type *Ty = D.getType().getTypePtr();
----------------
inconsistent east const vs west const
================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1859-1860
+static bool isEmptyClass(VarDecl const &D) {
+ const Type *Ty = D.getType().getTypePtr();
+ if (const auto *CxxRecordTy = Ty->getAsCXXRecordDecl())
+ return CxxRecordTy->isEmpty();
----------------
You check if `CxxRecordTy` is `nullptr`; do you need to check if `Ty` is `nullptr` as well?
================
Comment at: clang/lib/CodeGen/CGDecl.cpp:1860
+ const Type *Ty = D.getType().getTypePtr();
+ if (const auto *CxxRecordTy = Ty->getAsCXXRecordDecl())
+ return CxxRecordTy->isEmpty();
----------------
What about `RecordDecl`'s in general?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155580/new/
https://reviews.llvm.org/D155580
More information about the cfe-commits
mailing list