diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-09-28 23:48:55 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-09-28 23:48:55 +0000 |
commit | a8173bad4e2afe1d21cc457947b58f91dd148792 (patch) | |
tree | d3b94dbfca5eb9512748929455802eb32e5b8c0b /clang/lib/Sema/SemaExprMember.cpp | |
parent | a9aa270c67ff71a4db418ff949a5aac1892e8a52 (diff) | |
download | bcm5719-llvm-a8173bad4e2afe1d21cc457947b58f91dd148792.tar.gz bcm5719-llvm-a8173bad4e2afe1d21cc457947b58f91dd148792.zip |
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.
llvm-svn: 248761
Diffstat (limited to 'clang/lib/Sema/SemaExprMember.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 9c50605b82a..52dfceccb94 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/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<RecordMemberExprValidatorCCC>(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()); |