]> granicus.if.org Git - clang/commitdiff
Remove the only use of LookupResult's implicit copy ctor
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 28 Sep 2015 23:48:55 +0000 (23:48 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 28 Sep 2015 23:48:55 +0000 (23:48 +0000)
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

lib/Sema/SemaExprMember.cpp

index 9c50605b82a439431a38355d76116f4e5e53e227..52dfceccb94eff8fd8233b679c100e60478823c8 100644 (file)
@@ -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());