File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -644,14 +644,31 @@ std::string GetClassName(clang::QualType type) {
644644 return {};
645645}
646646
647+ static bool IsIteratorType (clang::QualType qt) {
648+ if (auto *record = qt->getAsCXXRecordDecl ()) {
649+ for (auto *d : record->decls ()) {
650+ if (auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(d)) {
651+ if (tnd->getName () == " iterator_category" )
652+ return true ;
653+ }
654+ }
655+ }
656+ return false ;
657+ }
658+
647659bool IsRedundantCopyInConversion (clang::ASTContext &ctx,
648660 const clang::CXXConstructExpr *expr) {
649- auto parents = ctx.getParentMapContext ().getParents (*expr);
650- if (parents.empty ()) {
651- return false ;
661+ if (auto parents = ctx.getParentMapContext ().getParents (*expr);
662+ !parents.empty ()) {
663+ if (auto *parent = parents[0 ].get <clang::CXXConstructExpr>()) {
664+ if (parent->getConstructor ()->isConvertingConstructor (
665+ /* AllowExplicit= */ false )) {
666+ return IsIteratorType (expr->getType ()) &&
667+ IsIteratorType (parent->getType ());
668+ }
669+ }
652670 }
653- auto *parent = parents[0 ].get <clang::CXXConstructExpr>();
654- return parent && parent->getConstructor ()->isConvertingConstructor (false );
671+ return false ;
655672}
656673
657674bool 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