[PATCH] D119525: [clang] Fix crash when array size is missing in initializer

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 11 05:55:51 PST 2022


aaron.ballman added a comment.

In D119525#3313554 <https://reviews.llvm.org/D119525#3313554>, @tbaeder wrote:

> This is a pretty big gotcha at best and I feel like `getArraySize()` should return `None` in that case instead... thoughts?

I think it is a gotcha -- some places protect against a null pointer (https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/TreeTransform.h#L11923 and https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/StmtPrinter.cpp#L2138) while other places assume the pointer isn't null (https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprCXX.cpp#L731 and https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ExprConstant.cpp#L9431). So I think a better approach is to fix up the interface so it doesn't return nullptr rather than play whack-a-mole forever with the API (and fix up the places currently checking for nullptr explicitly).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119525/new/

https://reviews.llvm.org/D119525



More information about the cfe-commits mailing list