================ @@ -2465,6 +2465,27 @@ CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base, if (Base->isPRValue() && Base->getType()->isRecordType()) return this; + // Handle array subscripts with constant indices when the pointee type is + // known + if (const auto *ASE = dyn_cast<ArraySubscriptExpr>(Base)) { + QualType BaseTy = ASE->getBase()->getType(); + + // Check if it's a pointer to a record type + if (BaseTy->isPointerType() && BaseTy->getPointeeType()->isRecordType()) { + // For C++17 and later, we can devirtualize array access beyond p[0] ---------------- erichkeane wrote:
I don't see the 'beyond [0]' in that standardeeze, can you better clarify it? Also, where are you checking for >0 here? It seems like you'd do this in every case? What is making this skip the 0 case? https://github.com/llvm/llvm-project/pull/130528 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits