[PATCH] D133570: Clang codegen, fixes issue with emitting partially initialized constant arrays larger than 2^32
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 9 10:40:45 PDT 2022
efriedma added inline comments.
================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1225
assert(CAT && "can't emit array init for non-constant-bound array");
- unsigned NumInitElements = ILE->getNumInits();
- unsigned NumElements = CAT->getSize().getZExtValue();
+ uint64_t NumInitElements = ILE->getNumInits();
+ uint64_t NumElements = CAT->getSize().getZExtValue();
----------------
Note that getNumInits() itself is returning "unsigned". (Looks easy to fix, though.)
================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1265
+
+ Inits.push_back(llvm::ConstantAggregateZero::get(FillerType));
+
----------------
Need to be careful here: in general, you can't just fill everything with zero. Need to check how getArrayFiller() is lowered. (For example, consider `class X; int X::*a[10] = { 0 };`.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133570/new/
https://reviews.llvm.org/D133570
More information about the cfe-commits
mailing list