1313#include < string>
1414#include < unordered_map>
1515#include < unordered_set>
16+ #include < utility>
1617#include < vector>
1718
1819#include " converter/lex.h"
@@ -547,8 +548,9 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
547548 PushSuppressIteratorClone (Converter &c, clang::CXXConstructExpr *expr)
548549 : c(c), prev(c.suppress_iterator_clone_) {
549550 auto *ctor = expr->getConstructor ();
550- if (ctor->isConvertingConstructor (/* AllowExplicit=*/ false ) &&
551- ctor->getNumParams () == 1 && IsIteratorType (expr->getType ())) {
551+ if (!ctor->isCopyOrMoveConstructor () &&
552+ ctor->isConvertingConstructor (/* AllowExplicit=*/ false ) &&
553+ ctor->getNumParams () == 1 ) {
552554 c.suppress_iterator_clone_ = true ;
553555 }
554556 }
@@ -557,24 +559,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
557559 PushSuppressIteratorClone &
558560 operator =(const PushSuppressIteratorClone &) = delete ;
559561
560- static bool take (Converter &c, clang::CXXConstructExpr *inner) {
561- bool suppress =
562- c.suppress_iterator_clone_ && IsIteratorType (inner->getType ());
563- c.suppress_iterator_clone_ = false ;
564- return suppress;
565- }
566-
567- private:
568- static bool IsIteratorType (clang::QualType qt) {
569- if (auto *record = qt->getAsCXXRecordDecl ()) {
570- for (auto *d : record->decls ()) {
571- if (auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(d)) {
572- if (tnd->getName () == " iterator_category" )
573- return true ;
574- }
575- }
576- }
577- return false ;
562+ static bool take (Converter &c) {
563+ return std::exchange (c.suppress_iterator_clone_ , false );
578564 }
579565 };
580566
0 commit comments