================
@@ -62,22 +57,33 @@ bool StoreToImmutableChecker::isConstVariable(const 
MemRegion *MR,
       return true;
   }
 
-  // Check if this is an ElementRegion accessing a const array
-  if (const ElementRegion *ER = dyn_cast<ElementRegion>(MR)) {
-    return isConstQualifiedType(ER->getSuperRegion(), C);
-  }
+  // NOTE: The only kind of region that is not checked by the above branches is
+  // AllocaRegion. We do not need to check AllocaRegion, as it models untyped
+  // memory, that is allocated on the stack.
 
   return false;
 }
 
-bool StoreToImmutableChecker::isConstQualifiedType(const MemRegion *MR,
-                                                   CheckerContext &C) const {
-  // Check if the region has a const-qualified type
-  if (const TypedValueRegion *TVR = dyn_cast<TypedValueRegion>(MR)) {
-    QualType Ty = TVR->getValueType();
-    return Ty.isConstQualified();
+bool StoreToImmutableChecker::isEffectivelyConstRegion(
+    const MemRegion *MR, CheckerContext &C) const {
+  // If the region is an ElementRegion, we need to check if any of the super
+  // regions have const-qualified type.
+  if (const ElementRegion *ER = dyn_cast<ElementRegion>(MR)) {
----------------
gamesh411 wrote:

True, fixed

https://github.com/llvm/llvm-project/pull/150417
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to