On Mon, Oct 14, 2013 at 7:05 AM, Serge Pavlov <[email protected]> wrote:
> Author: sepavloff > Date: Mon Oct 14 09:05:48 2013 > New Revision: 192594 > > URL: http://llvm.org/viewvc/llvm-project?rev=192594&view=rev > Log: > Do not use typo correction that is unaccessible. > This patch fixes PR17019. When doing typo correction, Sema::CorrectTypo > uses > correction already seen for the same typo. This causes problems if that > correction is from another scope and cannot be accessed in the current. > > Modified: > cfe/trunk/lib/Sema/SemaLookup.cpp > cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp > cfe/trunk/test/SemaObjC/bad-property-synthesis-crash.m > cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m > > Modified: cfe/trunk/lib/Sema/SemaLookup.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=192594&r1=192593&r2=192594&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) > +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Oct 14 09:05:48 2013 > @@ -4167,8 +4167,15 @@ TypoCorrection Sema::CorrectTypo(const D > // keyword case, we'll end up adding the keyword below. > if (Cached->second) { > if (!Cached->second.isKeyword() && > - isCandidateViable(CCC, Cached->second)) > - Consumer.addCorrection(Cached->second); > + isCandidateViable(CCC, Cached->second)) { > + // Do not use correction that is unaccessible in the given > scope. + NamedDecl* CorrectionDecl = Cached->second.getCorrectionDecl(); > * on the right, please. > + DeclarationNameInfo NameInfo(CorrectionDecl->getDeclName(), > + CorrectionDecl->getLocation()); > + LookupResult R(*this, NameInfo, LookupOrdinaryName); > + if (LookupName(R, S)) > + Consumer.addCorrection(Cached->second); > + } > } else { > // Only honor no-correction cache hits when a callback that will > validate > // correction candidates is not being used. > > Modified: cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp?rev=192594&r1=192593&r2=192594&view=diff > > ============================================================================== > --- cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp (original) > +++ cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp Mon Oct 14 09:05:48 2013 > @@ -151,3 +151,20 @@ struct S { > void f() { my_menber = 1; } // expected-error {{use of undeclared > identifier 'my_menber'; did you mean 'my_member'?}} > }; > } > + > +namespace PR17019 { > + template<class F> > + struct evil { > + evil(F de) { // expected-note {{'de' declared here}} > + de_; // expected-error {{use of undeclared identifier 'de_'; did > you mean 'de'?}} \ > + // expected-warning {{expression result unused}} > + } > + ~evil() { > + de_->bar() // expected-error {{use of undeclared identifier 'de_'}} > + } > + }; > + > + void meow() { > + evil<int> Q(0); // expected-note {{in instantiation of member > function}} > + } > +} > > Modified: cfe/trunk/test/SemaObjC/bad-property-synthesis-crash.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/bad-property-synthesis-crash.m?rev=192594&r1=192593&r2=192594&view=diff > > ============================================================================== > --- cfe/trunk/test/SemaObjC/bad-property-synthesis-crash.m (original) > +++ cfe/trunk/test/SemaObjC/bad-property-synthesis-crash.m Mon Oct 14 > 09:05:48 2013 > @@ -13,7 +13,7 @@ > __what; // expected-error {{use of undeclared identifier}} \ > // expected-warning {{expression result unused}} > } > -@synthesize what; // expected-note 2 {{'what' declared here}} > +@synthesize what; // expected-note {{'what' declared here}} > @end > > @implementation Bar // expected-warning {{cannot find interface > declaration for}} > > Modified: cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m?rev=192594&r1=192593&r2=192594&view=diff > > ============================================================================== > --- cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m (original) > +++ cfe/trunk/test/SemaObjC/error-outof-scope-property-use.m Mon Oct 14 > 09:05:48 2013 > @@ -6,7 +6,7 @@ > > @interface LaunchdJobs > > -@property (nonatomic,retain) NSMutableDictionary *uuids_jobs; // > expected-note 2 {{'_uuids_jobs' declared here}} > +@property (nonatomic,retain) NSMutableDictionary *uuids_jobs; // > expected-note {{'_uuids_jobs' declared here}} > > @end > > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
