================
@@ -4503,7 +4503,29 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
         E->getType(), !getLangOpts().PointerOverflowDefined, SignedIndices,
         E->getExprLoc(), &arrayType, E->getBase());
     EltBaseInfo = ArrayLV.getBaseInfo();
-    EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
+    if (!CGM.getCodeGenOpts().NewStructPathTBAA) {
+      // Since CodeGenTBAA::getTypeInfoHelper only handles array types for
+      // new struct path TBAA, we must a use a plain access.
+      EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
+    } else if (ArrayLV.getTBAAInfo().isMayAlias()) {
+      EltTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
+    } else if (ArrayLV.getTBAAInfo().isIncomplete()) {
+      // The array element is complete, even if the array is not.
+      EltTBAAInfo = CGM.getTBAAAccessInfo(E->getType());
+    } else {
+      // Extend struct path from base lvalue, similar to EmitLValueForField.
+      EltTBAAInfo = ArrayLV.getTBAAInfo();
+      // If no base type has been assigned for the array access, there is no
+      // point trying to generate one, since an array is not a valid base type.
+      //
+      // The index into the array is a runtime value. We use the same struct
+      // path for all array elements (that of the element at index 0). So we
+      // set the access type and size, but do not have to adjust
+      // EltTBAAInfo.Offset.
----------------
rjmccall wrote:

This comment doesn't seem to match the code anymore.

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

Reply via email to