File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -636,14 +636,31 @@ std::string GetClassName(clang::QualType type) {
636636 return {};
637637}
638638
639+ static bool IsIteratorType (clang::QualType qt) {
640+ if (auto *record = qt->getAsCXXRecordDecl ()) {
641+ for (auto *d : record->decls ()) {
642+ if (auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(d)) {
643+ if (tnd->getName () == " iterator_category" )
644+ return true ;
645+ }
646+ }
647+ }
648+ return false ;
649+ }
650+
639651bool IsRedundantCopyInConversion (clang::ASTContext &ctx,
640652 const clang::CXXConstructExpr *expr) {
641- auto parents = ctx.getParentMapContext ().getParents (*expr);
642- if (parents.empty ()) {
643- return false ;
653+ if (auto parents = ctx.getParentMapContext ().getParents (*expr);
654+ !parents.empty ()) {
655+ if (auto *parent = parents[0 ].get <clang::CXXConstructExpr>()) {
656+ if (parent->getConstructor ()->isConvertingConstructor (
657+ /* AllowExplicit= */ false )) {
658+ return IsIteratorType (expr->getType ()) &&
659+ IsIteratorType (parent->getType ());
660+ }
661+ }
644662 }
645- auto *parent = parents[0 ].get <clang::CXXConstructExpr>();
646- return parent && parent->getConstructor ()->isConvertingConstructor (false );
663+ return false ;
647664}
648665
649666bool IsVaListType (clang::QualType type) {
Original file line number Diff line number Diff line change @@ -1564,7 +1564,9 @@ bool ConverterRefCount::VisitCXXConstructExpr(clang::CXXConstructExpr *expr) {
15641564 }
15651565
15661566 if (ctor->isCopyConstructor ()) {
1567- StrCat (ConvertRValue (expr->getArg (0 )));
1567+ StrCat (IsRedundantCopyInConversion (ctx_, expr)
1568+ ? ConvertRValue (expr->getArg (0 ))
1569+ : ConvertFreshRValue (expr->getArg (0 )));
15681570 return false ;
15691571 }
15701572
You can’t perform that action at this time.
0 commit comments