[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 08:41:08 PST 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some minor nits. Can you also add a release note for the change?



================
Comment at: clang/include/clang/AST/ExprCXX.h:2271
+
+    if (auto Result =
+            cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
----------------



================
Comment at: clang/include/clang/AST/ExprCXX.h:2285
+
+    if (auto Result =
+            cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
----------------



================
Comment at: clang/lib/AST/StmtPrinter.cpp:2135
   std::string TypeS;
-  if (Optional<Expr *> Size = E->getArraySize()) {
+  if (E->isArray()) {
     llvm::raw_string_ostream s(TypeS);
----------------
tbaeder wrote:
> I changed this just for clarity, not doing it did not cause any tests to fail. Not sure if this is tested at all.
-ast-print is... pretty terrible (I've had half a mind to put up an RFC asking if we should remove it entirely, that's how unmaintained it is), so I suspect it's not tested.


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

https://reviews.llvm.org/D119525



More information about the cfe-commits mailing list