================
@@ -2606,30 +2606,46 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
   // objects accessed through array subscripts or pointer arithmetic with
   // non-zero offsets, since the dynamic type must match the static type.
   //
-  // A single object is considered to be an array of one element, so p[0]
-  // could still be a derived object, but p[N] for N != 0 cannot.
-  const Expr *Inner = Base->IgnoreParenImpCasts();
-  if (const auto *UO = dyn_cast<UnaryOperator>(Inner))
+  // Since a single object is treated as an array of one element for pointer
+  // arithmetic, p[0] could still designate a derived object, but p[N] for
+  // N != 0 cannot.
+  
+  auto CheckPointerArithmetic = [&](const Expr *Ptr) -> CXXMethodDecl * {
+    Ptr = Ptr->IgnoreParenBaseCasts();
----------------
zwuis wrote:

Perhaps we can move some logic to `Expr::getBestDynamicClassTypeExpr`.

https://github.com/llvm/llvm-project/pull/209593
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to