HerrCai0907 created this revision. HerrCai0907 added reviewers: shafik, erichkeane, aaron.ballman. Herald added a project: All. HerrCai0907 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fixed: https://github.com/llvm/llvm-project/issues/62945 c++20 supports "Permit conversions to arrays of unknown bound". This make it possible that ConstantArrayType is function parameter but IncompleteArrayType is argument (initializer list). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D151515 Files: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp Index: clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp =================================================================== --- clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp +++ clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp @@ -23,4 +23,13 @@ return r2; } + +// CHECK-LABEL: @_ZN3One3fooEi +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +void foo(int a) { + auto f = [](int(&&)[]) {}; + f({a}); +} + } // namespace One Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -4369,14 +4369,19 @@ CallExpr::const_arg_iterator Arg = ArgRange.begin(); for (QualType Ty : ArgTypes) { assert(Arg != ArgRange.end() && "Running over edge of argument list!"); - assert( - (isGenericMethod || Ty->isVariablyModifiedType() || - Ty.getNonReferenceType()->isObjCRetainableType() || - getContext() - .getCanonicalType(Ty.getNonReferenceType()) - .getTypePtr() == - getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && - "type mismatch in call argument!"); + // argument can be ConstantArrayType and parameter can be IncompleteArrayType + const Type *CanonicalTy = getContext() + .getCanonicalType(Ty.getNonReferenceType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + const Type *CanonicalArgTy = getContext() + .getCanonicalType((*Arg)->getType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + assert((isGenericMethod || Ty->isVariablyModifiedType() || + Ty.getNonReferenceType()->isObjCRetainableType() || + CanonicalTy == CanonicalArgTy) && + "type mismatch in call argument!"); ++Arg; }
Index: clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp =================================================================== --- clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp +++ clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp @@ -23,4 +23,13 @@ return r2; } + +// CHECK-LABEL: @_ZN3One3fooEi +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +void foo(int a) { + auto f = [](int(&&)[]) {}; + f({a}); +} + } // namespace One Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -4369,14 +4369,19 @@ CallExpr::const_arg_iterator Arg = ArgRange.begin(); for (QualType Ty : ArgTypes) { assert(Arg != ArgRange.end() && "Running over edge of argument list!"); - assert( - (isGenericMethod || Ty->isVariablyModifiedType() || - Ty.getNonReferenceType()->isObjCRetainableType() || - getContext() - .getCanonicalType(Ty.getNonReferenceType()) - .getTypePtr() == - getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && - "type mismatch in call argument!"); + // argument can be ConstantArrayType and parameter can be IncompleteArrayType + const Type *CanonicalTy = getContext() + .getCanonicalType(Ty.getNonReferenceType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + const Type *CanonicalArgTy = getContext() + .getCanonicalType((*Arg)->getType()) + .getTypePtr() + ->getPointeeOrArrayElementType(); + assert((isGenericMethod || Ty->isVariablyModifiedType() || + Ty.getNonReferenceType()->isObjCRetainableType() || + CanonicalTy == CanonicalArgTy) && + "type mismatch in call argument!"); ++Arg; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits