Author: rsmith Date: Tue Jan 31 21:28:59 2017 New Revision: 293740 URL: http://llvm.org/viewvc/llvm-project?rev=293740&view=rev Log: Remove apparently-unnecessary copy of constructor lookup result.
Contrary to the comment, DeclContext intends to guarantee that the lookup results for a particular name will be stable across non-AST-mutating operations, so a copy here should not be necessary. Further, if a copy *is* necessary, the other four instances of this pattern within this file would also be wrong, and we have no evidence of any problems with them; if this change unearths problems, we should fix all the instances of this pattern. Modified: cfe/trunk/lib/Sema/SemaInit.cpp Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=293740&r1=293739&r2=293740&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jan 31 21:28:59 2017 @@ -4679,15 +4679,7 @@ static void TryUserDefinedConversion(Sem // Try to complete the type we're converting to. if (S.isCompleteType(Kind.getLocation(), DestType)) { - DeclContext::lookup_result R = S.LookupConstructors(DestRecordDecl); - // The container holding the constructors can under certain conditions - // be changed while iterating. To be safe we copy the lookup results - // to a new container. - SmallVector<NamedDecl*, 8> CopyOfCon(R.begin(), R.end()); - for (SmallVectorImpl<NamedDecl *>::iterator - Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end(); - Con != ConEnd; ++Con) { - NamedDecl *D = *Con; + for (NamedDecl *D : S.LookupConstructors(DestRecordDecl)) { auto Info = getConstructorInfo(D); if (!Info.Constructor) continue; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits