[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 13:24:03 PDT 2022


shafik added inline comments.


================
Comment at: clang/include/clang/AST/APValue.h:511-512
   bool hasArrayFiller() const {
+    if (!isArray())
+      return false;
     return getArrayInitializedElts() != getArraySize();
----------------
aaron.ballman wrote:
> I think this makes the interface somewhat self-inconsistent. `hasLValuePath()` asserts on `isLValue()`, and `getArraySize()` was providing a similar assertion (on `isArray()`) when called from `hasArrayFiller()`.
> 
> I take that to mean that the expectation for this interface is that the caller validates the `APValue` in the cases where it doesn't already know the answer.
I agree with Aaron here, the correct place to fix this is in `VisitInitListExpr` and check `Result.isArray()`.




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

https://reviews.llvm.org/D128248



More information about the cfe-commits mailing list