Author: Nikita Popov Date: 2021-12-27T12:58:22+01:00 New Revision: 3e6586113157c164d39120139c14295058e88ccb
URL: https://github.com/llvm/llvm-project/commit/3e6586113157c164d39120139c14295058e88ccb DIFF: https://github.com/llvm/llvm-project/commit/3e6586113157c164d39120139c14295058e88ccb.diff LOG: [CodeGen] Avoid one more pointer element type access The number of elements is always a SizeTy here. Added: Modified: clang/lib/CodeGen/CGDecl.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index e09279c1d455..36185faf942f 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1392,9 +1392,11 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions( else { // Create an artificial VarDecl to generate debug info for. IdentifierInfo *NameIdent = VLAExprNames[NameIdx++]; - auto VlaExprTy = VlaSize.NumElts->getType()->getPointerElementType(); + assert(cast<llvm::PointerType>(VlaSize.NumElts->getType()) + ->isOpaqueOrPointeeTypeMatches(SizeTy) && + "Number of VLA elements must be SizeTy"); auto QT = getContext().getIntTypeForBitwidth( - VlaExprTy->getScalarSizeInBits(), false); + SizeTy->getScalarSizeInBits(), false); auto *ArtificialDecl = VarDecl::Create( getContext(), const_cast<DeclContext *>(D.getDeclContext()), D.getLocation(), D.getLocation(), NameIdent, QT, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits