From: David Blaikie Date: Mon, 28 Sep 2015 23:48:55 +0000 (+0000) Subject: Remove the only use of LookupResult's implicit copy ctor X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47af8de8a71edbb0cf7974b9ce0b25167745e66f;p=clang Remove the only use of LookupResult's implicit copy ctor LookupResult should not be copyable, it's not readily copyable and can only be copied when it's in specific states (in a query state, without any results, basically). Instead, just extract the /query/ state and pass that across the copy boundary, then build a new LookupResult on the other side. I wonder if a better API (one in which the query state is separate from the result state - essentialyl making QueryState a first class part of the Lookup API - pass a QueryState, get a LookupResult, rather than mutating the LookupResult in place (LookupResult could contain a QueryState if it's particularly helpful to be able to observe the query parameters while also examining the result)) might be a good idea here. Future patches will probably make LookupResult actually non-copyable (transition the CXXBasePaths to unique_ptr, for example) and hopefully we'll enable -Wdeprecated in LLVM soon to avoid issues like this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248761 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 9c50605b82..52dfceccb9 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -632,6 +632,16 @@ static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, DeclarationName Typo = R.getLookupName(); SourceLocation TypoLoc = R.getNameLoc(); + + struct QueryState { + Sema &SemaRef; + DeclarationNameInfo NameInfo; + Sema::LookupNameKind LookupKind; + Sema::RedeclarationKind Redecl; + }; + QueryState Q = {R.getSema(), R.getLookupNameInfo(), R.getLookupKind(), + R.isForRedeclaration() ? Sema::ForRedeclaration + : Sema::NotForRedeclaration}; TE = SemaRef.CorrectTypoDelayed( R.getLookupNameInfo(), R.getLookupKind(), nullptr, &SS, llvm::make_unique(RTy), @@ -650,6 +660,7 @@ static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, } }, [=](Sema &SemaRef, TypoExpr *TE, TypoCorrection TC) mutable { + LookupResult R(Q.SemaRef, Q.NameInfo, Q.LookupKind, Q.Redecl); R.clear(); // Ensure there's no decls lingering in the shared state. R.suppressDiagnostics(); R.setLookupName(TC.getCorrection());